GetResultType Method

ObjectQuery.GetResultType Method ()

.NET Framework (current version)
 

Returns information about the result type of the query.

Namespace:   System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public TypeUsage GetResultType()

Return Value

Type: System.Data.Metadata.Edm.TypeUsage

A TypeUsage value that contains information about the result type of the query.

This example is based on the AdventureWorks Sales Model. 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);
    }
}

.NET Framework
Available since 3.5

ObjectQuery Class
System.Data.Objects Namespace
Managing Connections in Object Services (Entity Framework)
ADO.NET Metadata

Return to top
Show:
© 2016 Microsoft