Entity Framework 根据泛型获取对象的方法

2024-11-29 05:27:44
推荐回答(1个)
回答(1):

using (AdventureWorksEntities context =
new AdventureWorksEntities())
{
string queryString =
@"SELECT VALUE contact FROM AdventureWorksEntities.Contacts
AS contact WHERE contact.FirstName = @fn";

var result =
(context.CreateQuery(queryString,
new ObjectParameter("fn", "Frances"))).AsQueryable();

}