ObjectQuery.GetResultType 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回查詢結果類型的相關信息。
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);
}
}