Entity Framework 根据泛型获取对象的方法
谁知道EntityFramework里的ObjectContext类中有没有类似linq的DataContext类里的GetTable()方法?简单说就是我要用Objec...
谁知道 Entity Framework 里的 ObjectContext类中有没有类似
linq 的DataContext类里的GetTable()方法?
简单说就是我要用ObjectContext类根据一个泛型获取IQueryable<T>对象 展开
linq 的DataContext类里的GetTable()方法?
简单说就是我要用ObjectContext类根据一个泛型获取IQueryable<T>对象 展开
1个回答
2013-04-12
展开全部
using (AdventureWorksEntities context =
new AdventureWorksEntities())
{
string queryString =
@"SELECT VALUE contact FROM AdventureWorksEntities.Contacts
AS contact WHERE contact.FirstName = @fn";
var result =
(context.CreateQuery<Contact>(queryString,
new ObjectParameter("fn", "Frances"))).AsQueryable<Contact>();
}
new AdventureWorksEntities())
{
string queryString =
@"SELECT VALUE contact FROM AdventureWorksEntities.Contacts
AS contact WHERE contact.FirstName = @fn";
var result =
(context.CreateQuery<Contact>(queryString,
new ObjectParameter("fn", "Frances"))).AsQueryable<Contact>();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询