LinkEntity 類別
Specifies the links between multiple entity types used in creating complex queries.
命名空間: Microsoft.Xrm.Sdk.Query
組件: Microsoft.Xrm.Sdk (在 Microsoft.Xrm.Sdk.dll 中)
語法
'宣告
<DataContractAttribute(Name:="LinkEntity", Namespace:="https://schemas.microsoft.com/xrm/2011/Contracts")> _
Public NotInheritable Class LinkEntity
Implements IExtensibleDataObject
[DataContractAttribute(Name="LinkEntity", Namespace="https://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class LinkEntity : IExtensibleDataObject
範例
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"]);
繼承階層
System.Object
Microsoft.Xrm.Sdk.Query.LinkEntity
執行緒安全
此類型的任何公用靜態 (Visual Basic 中的 Shared) 成員都具備執行緒安全。任何執行個體成員都不保證具備執行緒安全。
平台
Development Platforms
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Target Platforms
Windows Server 2008、Windows Server 2012、Windows 7
Change History
請參閱
參照
LinkEntity 成員
Microsoft.Xrm.Sdk.Query 命名空間
LinkEntities
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.