LinkEntity クラス

適用対象: CRM 2015 on-prem, CRM Online

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) メンバーはスレッド セーフです。インスタンス メンバーがスレッド セーフであることは保証されません。

プラットフォーム

開発プラットフォーム

Windows Vista、Windows Server 2003、および

対象プラットフォーム

Windows Vista、Windows XP

Change History

関連項目

参照

LinkEntity のメンバー
Microsoft.Xrm.Sdk.Query 名前空間
LinkEntities

Send comments about this topic to Microsoft.
© 2014 Microsoft Corporation. All rights reserved.