我正在使用Entity框架6。 我需要传入两个表名并创建一个LINQ查询,我将能够使用它来填充Kendo数据源。
这是我目前正在尝试更改为动态的代码。
var entryPoint = (from pd in db.Employees
join od in db.MessageEmployees on pd.EmpID equals od.EmployeeID into t
from rt in t.DefaultIfEmpty()
where pd.Class == clssID && pd.IsInactive == 0
orderby pd.Class
select new
{
ClassID = pd.Class,
pd.FirstName,
pd.LastName,
pd.EmpID,
pd.EmployeeID,
EmpMessageID = rt.EmployeeID
});
//IQueryable<Employee> emps = db.Employees;
DataSourceResult result = entryPoint.ToDataSourceResult(request, empl => new HierachyEmployee
{
ClassID = empl.ClassID,
FirstName = empl.FirstName,
LastName = empl.LastName,
EmpID = empl.EmpID,
IsChecked = empl.EmpMessageID != null
});
return Json(result);
我需要db.MessageEmployees和db.Employees是动态的。提前感谢您的帮助。