ObjectQuery.GetResultType Method

Definition

Gibt Informationen über den Ergebnistyp der Abfrage zurück.Returns information about the result type of the query.

public:
 System::Data::Metadata::Edm::TypeUsage ^ GetResultType();
public System.Data.Metadata.Edm.TypeUsage GetResultType ();
member this.GetResultType : unit -> System.Data.Metadata.Edm.TypeUsage
Public Function GetResultType () As TypeUsage

Returns

TypeUsage

Ein TypeUsage-Wert, der Informationen über den Ergebnistyp der Abfrage enthält.A TypeUsage value that contains information about the result type of the query.

Examples

Dieses Beispiel basiert auf den Microsoft SQL Server Product Samples: Database.This example is based on the Microsoft SQL Server Product Samples: Database. Im Beispiel wird eine ObjectQuery<T> des Typs DbDataRecord erstellt, und mit GetResultType wird ermittelt, ob der zurückgegebene Typ eine Zeile darstellt.The example creates an ObjectQuery<T> of type DbDataRecord and uses GetResultType to determine whether the type returned represents a row.

using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString = @"SELECT VALUE product "
    + "FROM AdventureWorksEntities.Products AS product";
    ObjectQuery<DbDataRecord> query =
        new ObjectQuery<DbDataRecord>
            (queryString, context);

    TypeUsage type = query.GetResultType();
    if (type.EdmType is RowType)
    {
        RowType row = type.EdmType as RowType;
        foreach (EdmProperty column in row.Properties)
            Console.WriteLine("{0}", column.Name);
    }
}
Using context As New AdventureWorksEntities()
    Dim queryString As String = "SELECT VALUE product " & "FROM AdventureWorksEntities.Products AS product"
    Dim query As New ObjectQuery(Of DbDataRecord)(queryString, context)

    Dim type As TypeUsage = query.GetResultType()
    If TypeOf type.EdmType Is RowType Then
        Dim row As RowType = TryCast(type.EdmType, RowType)
        For Each column As EdmProperty In row.Properties
            Console.WriteLine("{0}", column.Name)
        Next
    End If
End Using

Applies to

See also