共用方式為


ObjectQuery.GetResultType 方法

定義

傳回查詢之結果型別的相關資訊。

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

傳回

TypeUsage 值,其中包含查詢之結果型別的相關資訊。

範例

這個範例會 ObjectQuery<T> 建立 型 DbDataRecord 別的 ,並使用 GetResultType 來判斷傳回的類型是否代表數據列。

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);
    }
}

適用於

另請參閱