How Can I Join On Two Columns with a LinkEntity in CRM 2011?

I am using a Link Entity to join a two entities:

LinkEntity pricelevelentity = new LinkEntity();
pricelevelentity.JoinOperator = JoinOperator.Inner;
pricelevelentity.LinkFromEntityName = "product";
pricelevelentity.LinkFromAttributeName = "productid";

pricelevelentity.LinkToEntityName = "productpricelevel";
pricelevelentity.LinkToAttributeName = "productid";
query.LinkEntities.Add(pricelevelentity);

The above is joining Product and ProductPriceLevel on the ProductId attribute. I also want to add to the join Product.uomid on ProductPriceLevel.DefaultUomId

How can i do this?

Answers


If you are attempting to return a column for a linked/joined entity to be able to perform additional filtering on the client side, LinkEntity has a Column property you should use, for example:

new QueryExpression("product")
{
    ColumnSet = new ColumnSet("oumid"),
    LinkEntities =
    {
        new LinkEntity("product", "productpricelevel", "productid", "productid", JoinOperator.Inner)
        {
            Columns = new ColumnSet("defaultuomid")
        }
    }
};

Need Your Help

Using hibernate UPDATE column of type “datetime” for mysql

mysql hibernate datetime orm

I am using Hibernate for ORM mapping. One of the tables has a column of type "datetime". The column in question needs to be updated with "current-time" (time of data insertion). I am aware that I c...

WPF custom control objects databinding to List(T) based on query

wpf linq-to-sql generics data-binding custom-controls

In a window of my WPF application I have several hundreds of objects, they based on a custom control. They differ from each other only by name:

Raise a OnTextChanged event in winforms TextBox

c# winforms

How can I raise an event that will call my OnTextChanged overridden method for my textbox control?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.