ASP.NET MVC 4
实体框架:6.1.3
我尝试根据GET参数"表单" 从表名中选择数据。
我的控制器包含以下代码:
...
using System.Linq;
...
public ActionResult Index(string form, int? page)
{
Type MyTable1Type, MyTable2Type;
Dictionary<string, Type> TableType = new Dictionary<string, Type>()
{
{ "MyTable1", MyTable1Type},
{ "MyTable2", MyTable2Type}
};
var query = db.Set(TableType[form]);
var records = query.Select(x => x).Where(x => (!x.user_action.user.email.ToLower().Contains("@example.com")));
// Pagination
int PageIndex = page.HasValue ? page.Value : 1;
var results = records.OrderByDescending(x => x.user_action.date_created).ToList().ToPagedList(PageIndex, PageSize);
return View(results);
}
错误消息:
'System.Data.Entity.DbSet' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Data.Entity.DbSet' could be found (are you missing a using directive or an assembly reference?)
你能帮忙吗?谢谢。 :)