Bestellergebnisse mithilfe von LINQ der Entitätsattributen
Veröffentlicht: Januar 2017
Gilt für: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online
In Microsoft Dynamics 365 und Microsoft Dynamics 365 (online) können Sie Such- oder Optionen (Auswahlliste)-Attribute verwenden, um Ergebnisse innerhalb der LINQ-Abfrage zu finden. Dieses Thema zeigt verschiedene Beispiele dieser Art von Abfragen an.
Verwenden eines Suchwerts für Bestellt durch
Das folgende Beispiel zeigt das Suchattribut PrimaryContactId in einer Order By Klausel.
using (ServiceContext svcContext = new ServiceContext(_serviceProxy))
{
var query_orderbylookup = from a in svcContext.AccountSet
where a.Address1_Name == "Contoso Pharmaceuticals"
orderby a.PrimaryContactId
select new
{
a.Name,
a.Address1_City
};
foreach (var a in query_orderbylookup)
{
System.Console.WriteLine(a.Name + " " + a.Address1_City);
}
}
Using svcContext As New ServiceContext(_serviceProxy)
Dim query_orderbylookup = From a In svcContext.AccountSet _
Where a.Address1_Name.Equals("Contoso Pharmaceuticals") _
Order By a.PrimaryContactId _
Select New With {Key a.Name,
Key a.Address1_City}
For Each a In query_orderbylookup
Console.WriteLine(a.Name & " " & a.Address1_City)
Next a
End Using
Verwendung einer Auswahlliste für Bestellt durch
Das folgende Beispiel zeigt uns die Verwendung des Suchwerts für Bestellt durch.
using (ServiceContext svcContext = new ServiceContext(_serviceProxy))
{
var query_orderbypicklist = from c in svcContext.ContactSet
where c.LastName != "Parker" &&
c.AccountRoleCode != null
orderby c.AccountRoleCode, c.FirstName
select new
{
AccountRole = c.FormattedValues["accountrolecode"],
c.FirstName,
c.LastName
};
foreach (var c in query_orderbypicklist)
{
System.Console.WriteLine(c.AccountRole + " " +
c.FirstName + " " + c.LastName);
}
}
Using svcContext As New ServiceContext(_serviceProxy)
Dim query_orderbypicklist = From c In svcContext.ContactSet _
Where c.LastName IsNot "Parker" _
AndAlso c.AccountRoleCode IsNot Nothing _
Order By c.AccountRoleCode, c.FirstName _
Select New With
{Key .AccountRole =
c.FormattedValues("accountrolecode"),
Key c.FirstName, Key c.LastName}
For Each c In query_orderbypicklist
Console.WriteLine(c.AccountRole & " " & c.FirstName _
& " " & c.LastName)
Next c
End Using
Siehe auch
Erstellen von Abfragen mit LINQ (.NET language-integrated query)
Auslagern von umfangreichen Ergebnissätzen mit LINQ
Microsoft Dynamics 365
© 2017 Microsoft. Alle Rechte vorbehalten. Copyright