本文整理匯總了C#中System.Data.Objects.ObjectQuery.Parameters屬性的典型用法代碼示例。如果您正苦於以下問題:C# ObjectQuery.Parameters屬性的具體用法?C# ObjectQuery.Parameters怎麽用?C# ObjectQuery.Parameters使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。
在下文中一共展示了ObjectQuery.Parameters屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: using
//引入命名空間
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;
// Iterate through the ObjectParameterCollection.
foreach (ObjectParameter result in objectParameterCollection)
{
Console.WriteLine("{0} {1} {2}", result.Name,
result.Value,
result.ParameterType);
}
}