我有下面的代码,应该会给我带来一个用户列表。我正在测试“Take”功能来进行分页,但它不起作用。
using (MyContainer myContainer = new MyContainer())
{
// Works
var user = myContainer.User.Where(u => u.Name == Name).ToList();
// The "Name" comes from User.Name
// myContainer is generated by my edmx he inherits the ObjectContext in the design generated by edmx as it shows below
//// public partial class MyContainer : ObjectContext
// Does not work
var foo = (from t in myContainer.User
select t.Name).Take(10);
return user;
}
为什么与第一个如此相似不起作用。
抛出异常“无法将 Lambda 表达式转换为类型‘字符串’,因为它不是委托类型”