ObjectParameterCollection.Contains メソッド
定義
指定した ObjectParameter がコレクション内に存在するかどうかを参照によって確認します。Checks for the existence of a specified ObjectParameter in the collection by reference.
オーバーロード
Contains(ObjectParameter) |
指定した ObjectParameter がコレクション内に存在するかどうかを参照によって確認します。Checks for the existence of a specified ObjectParameter in the collection by reference. |
Contains(String) |
指定した名前の ObjectParameter がコレクション内に存在するかどうかを調べます。Determines whether an ObjectParameter with the specified name is in the collection. |
Contains(ObjectParameter)
指定した ObjectParameter がコレクション内に存在するかどうかを参照によって確認します。Checks for the existence of a specified ObjectParameter in the collection by reference.
public:
virtual bool Contains(System::Data::Objects::ObjectParameter ^ parameter);
public bool Contains (System.Data.Objects.ObjectParameter parameter);
abstract member Contains : System.Data.Objects.ObjectParameter -> bool
override this.Contains : System.Data.Objects.ObjectParameter -> bool
Public Function Contains (parameter As ObjectParameter) As Boolean
パラメーター
- parameter
- ObjectParameter
コレクション内で検索する ObjectParameter。The ObjectParameter to find in the collection.
戻り値
パラメーター オブジェクトがコレクション内で見つかった場合は true
。それ以外の場合は false
。true
if the parameter object was found in the collection; otherwise, false
.
実装
例外
parameter
引数が null
です。The parameter
argument is null
.
注釈
これは参照に基づく確認です。This is a reference-based check. つまり、コレクション内のObjectParameterパラメーターオブジェクトと同じ名前を持つが指定されている場合、このメソッドは、同じtrue
オブジェクトである場合にのみを返します。That is, if an ObjectParameter is specified that contains the same name as a parameter object in the collection, this method will only return true
if it is the same object.
Contains(String)
指定した名前の ObjectParameter がコレクション内に存在するかどうかを調べます。Determines whether an ObjectParameter with the specified name is in the collection.
public:
bool Contains(System::String ^ name);
public bool Contains (string name);
member this.Contains : string -> bool
Public Function Contains (name As String) As Boolean
パラメーター
- name
- String
コレクション内で検索するパラメーターの名前。The name of the parameter to look for in the collection. この名前には、Entity SQL ステートメントで使用される "@" パラメーター マーカーは含めないでください。実際の名前だけにする必要があります。This name should not include the "@" parameter marker that is used in the Entity SQL statements, only the actual name.
戻り値
指定された名前のパラメーターがコレクション内で見つかった場合は true
。それ以外の場合は false
。true
if a parameter with the specified name was found in the collection; otherwise, false
.
例外
name
パラメーターが null
です。The name
parameter is null
.
例
このトピックの例は、 AdventureWorks Sales Modelに基づいています。The example in this topic is based on the AdventureWorks Sales Model. この例では、Contains メソッドを使用して、指定したパラメーターがコレクション内に存在するかどうかを調べます。The example uses the Contains method to determine whether the specified parameter is in the collection.
using (AdventureWorksEntities context =
new AdventureWorksEntities())
{
string queryString =
@"SELECT VALUE contact FROM AdventureWorksEntities.Contacts
AS contact WHERE contact.LastName = @ln AND contact.FirstName = @fn";
ObjectQuery<Contact> contactQuery =
new ObjectQuery<Contact>(queryString, context);
// Add parameters to the collection.
contactQuery.Parameters.Add(new ObjectParameter("ln", "Adams"));
contactQuery.Parameters.Add(new ObjectParameter("fn", "Frances"));
ObjectParameterCollection objectParameterCollection =
contactQuery.Parameters;
if (objectParameterCollection.Contains("ln"))
Console.WriteLine("ln is here");
else
Console.WriteLine("ln is not here");
}
Using context As New AdventureWorksEntities()
Dim queryString As String = "SELECT VALUE contact FROM AdventureWorksEntities.Contacts " & _
" AS contact WHERE contact.LastName = @ln AND contact.FirstName = @fn"
Dim contactQuery As New ObjectQuery(Of Contact)(queryString, context)
' Add parameters to the collection.
contactQuery.Parameters.Add(New ObjectParameter("ln", "Adams"))
contactQuery.Parameters.Add(New ObjectParameter("fn", "Frances"))
Dim objectParameterCollection As ObjectParameterCollection = contactQuery.Parameters
If objectParameterCollection.Contains("ln") Then
Console.WriteLine("ln is here")
Else
Console.WriteLine("ln is not here")
End If
End Using