ObjectQuery<T>.SelectValue<TResultType> メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
クエリ結果をプロジェクションで指定されたプロパティのみに制限します。
public:
generic <typename TResultType>
System::Data::Objects::ObjectQuery<TResultType> ^ SelectValue(System::String ^ projection, ... cli::array <System::Data::Objects::ObjectParameter ^> ^ parameters);
public System.Data.Objects.ObjectQuery<TResultType> SelectValue<TResultType>(string projection, params System.Data.Objects.ObjectParameter[] parameters);
member this.SelectValue : string * System.Data.Objects.ObjectParameter[] -> System.Data.Objects.ObjectQuery<'ResultType>
Public Function SelectValue(Of TResultType) (projection As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of TResultType)
型パラメーター
- TResultType
SelectValue<TResultType>(String, ObjectParameter[]) メソッドによって返されるObjectQuery<T>の型。
パラメーター
- projection
- String
射影リスト。
- parameters
- ObjectParameter[]
解析時にスコープ内にある必要があるクエリ パラメーターのオプション セット。
返品
特定のプロジェクションと互換性のある型の新しい ObjectQuery<T> インスタンス。 返される ObjectQuery<T> は、 SELECT VALUE が適用された元のインスタンスと同じです。
例外
projectionは空の文字列です。
例
次の使用例は、既存のクエリの結果から投影される一連のProductID値である結果を含む新しいObjectQuery<T>を作成します。
using (AdventureWorksEntities context =
new AdventureWorksEntities())
{
string queryString =
@"SELECT VALUE product FROM
AdventureWorksEntities.Products AS product";
ObjectQuery<Product> productQuery1 =
new ObjectQuery<Product>(queryString,
context, MergeOption.NoTracking);
ObjectQuery<Int32> productQuery2 =
productQuery1.SelectValue<Int32>("it.ProductID");
foreach (Int32 result in productQuery2)
{
Console.WriteLine("{0}", result);
}
}
注釈
SelectValue は、単純型、エンティティ型、または複合型の値を返すために使用されます。 値型ではなく行型を必要とするプロジェクションには、 Select メソッドを使用します。 詳細については、「 オブジェクト クエリ」を参照してください。
SelectValue メソッドは、projection パラメーターで指定されたプロジェクションを適用します。
SelectValue メソッドによって返されるObjectQuery<T>は、プロジェクションと互換性があり、SelectValueの型と同じ型である必要があります。