LinkEntity Class

 

Updated: November 29, 2016

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Specifies the links between multiple entity types used in creating complex queries.

Namespace:   Microsoft.Xrm.Sdk.Query
Assembly:  Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

System.Object
  Microsoft.Xrm.Sdk.Query.LinkEntity

[DataContractAttribute(Name = "LinkEntity", Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class LinkEntity : IExtensibleDataObject

NameDescription
System_CAPS_pubmethodLinkEntity()

Initializes a new instance of the LinkEntity class.

System_CAPS_pubmethodLinkEntity(String, String, String, String, JoinOperator)

Initializes a new instance of the LinkEntity class setting the required properties.

NameDescription
System_CAPS_pubpropertyColumns

Gets or sets the column set.

System_CAPS_pubpropertyEntityAlias

Gets or sets the alias for the entity.

System_CAPS_pubpropertyExtensionData

Gets or sets the structure that contains extra data.

System_CAPS_pubpropertyJoinOperator

Gets or sets the join operator.

System_CAPS_pubpropertyLinkCriteria

Gets or sets the complex condition and logical filter expressions that filter the results of the query.

System_CAPS_pubpropertyLinkEntities

Gets the links between multiple entity types.

System_CAPS_pubpropertyLinkFromAttributeName

Gets or sets the logical name of the attribute of the entity that you are linking from.

System_CAPS_pubpropertyLinkFromEntityName

Gets or sets the logical name of the entity that you are linking from.

System_CAPS_pubpropertyLinkToAttributeName

Gets or sets the logical name of the attribute of the entity that you are linking to.

System_CAPS_pubpropertyLinkToEntityName

Gets or sets the logical name of the entity that you are linking to.

System_CAPS_pubpropertyOrders

NameDescription
System_CAPS_pubmethodAddLink(String, String, String)

Adds a link, setting the link to entity name, the link from attribute name and the link to attribute name.

System_CAPS_pubmethodAddLink(String, String, String, JoinOperator)

Adds a link setting the link to entity name, the link from attribute name, the link to attribute name, and the join operator.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)


q = new QueryExpression();
q.EntityName = "account";
q.ColumnSet = new ColumnSet();
q.ColumnSet.Columns.Add("name");

q.LinkEntities.Add(new LinkEntity("account", "contact", "primarycontactid", "contactid", JoinOperator.Inner));
q.LinkEntities[0].Columns.AddColumns("firstname", "lastname");
q.LinkEntities[0].EntityAlias = "temp";

q.Criteria = new FilterExpression();
q.Criteria.AddCondition("accountnumber", ConditionOperator.Equal, accountNumber);
q.Orders.Add(new OrderExpression("name", OrderType.Descending));
q.Distinct = true;
EntityCollection ec = this.Context.Proxy.RetrieveMultiple(q);

Log.Assert(ec.Entities.Count == 3, "Expected 3 entities, received {0}", ec.Entities.Count);
Log.Assert((string)ec.Entities[0]["name"] == "SdkAccount3", "First Entity should be SdkAccount3");
Log.Assert((string)ec.Entities[1]["name"] == "SdkAccount2", "First Entity should be SdkAccount2");
Log.Assert((string)ec.Entities[2]["name"] == "SdkAccount1", "First Entity should be SdkAccount1");
Log.Assert((string)((AliasedValue)ec.Entities[0]["temp.firstname"]).Value == (string)contact["firstname"], "Expected {0} Got {1}", contact["firstname"], ec.Entities[0]["temp.firstname"]);
Log.Assert((string)((AliasedValue)ec.Entities[1]["temp.lastname"]).Value == (string)contact["lastname"], "Expected {0} Got {1}", contact["lastname"], ec.Entities[1]["temp.lastname"]);

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright

Community Additions

ADD
Show: