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

WPF Events in Winforms

c# wpf winforms events event-bubbling

I have an Winforms application that is using a WPF control (Avalon Edit if it matters) inside an ElementHost.

Accessing a MKMapView through the tab bar

iphone objective-c uitabbarcontroller mapkit mkmapview

I have a tabbar application and on the first tab I have a MKMapView. What I want to do is from somewhere else in the application, switch the active tab to the mapview and set the mapview's region b...

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.