Dieser Artikel wurde manuell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. |
Übersetzung
Original
|
ObjectQuery<T>-Konstruktor (String, ObjectContext)
Erstellt eine neue ObjectQuery<T>-Instanz mit dem angegebenen Entity SQL-Befehl als erste Abfrage.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
Parameter
- commandText
- Typ: System.String
Die Entity SQL-Abfrage.
- context
- Typ: System.Data.Objects.ObjectContext
Der ObjectContext, für den die Abfrage ausgeführt werden soll.
Das Beispiel in diesem Thema beruht auf dem Adventure Works Sales Model. In dem Beispiel wird veranschaulicht, wie eine Instanz der ObjectQuery<T>-Klasse erstellt wird.
using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Call the constructor with a query for products and the ObjectContext. ObjectQuery<Product> productQuery1 = new ObjectQuery<Product>("Products", context); foreach (Product result in productQuery1) Console.WriteLine("Product Name: {0}", result.Name); string queryString = @"SELECT VALUE product FROM AdventureWorksEntities.Products AS product"; // Call the constructor with the specified query and the ObjectContext. ObjectQuery<Product> productQuery2 = new ObjectQuery<Product>(queryString, context); foreach (Product result in productQuery2) Console.WriteLine("Product Name: {0}", result.Name); // Call the constructor with the specified query, the ObjectContext, // and the NoTracking merge option. ObjectQuery<Product> productQuery3 = new ObjectQuery<Product>(queryString, context, MergeOption.NoTracking); foreach (Product result in productQuery3) Console.WriteLine("Product Name: {0}", result.Name); }
Windows 7, Windows Vista SP1 oder höher, Windows XP SP3, Windows Server 2008 (Server Core wird nicht unterstützt), Windows Server 2008 R2 (Server Core wird mit SP1 oder höher unterstützt), Windows Server 2003 SP2
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.
Community-Inhalt
Hinzufügen