我在我的 C# 项目中使用 DynamicLinq。
当我使用“order by”、“skip”等进行简单选择时,效果很好。
但是如果你加入restona简单错误:
Error 3 Instance argument: cannot convert from 'int?' to 'System.Linq.IQueryable' J:\C#\ERP\ERP\Helpers\ListagemPadrao.cs 23 25 ERP
Error 2 'int?' does not contain a definition for 'OrderBy' and the best extension method overload 'System.Linq.Dynamic.DynamicQueryable.OrderBy(System.Linq.IQueryable, string, params object[])' has some invalid arguments J:\C#\ERP\ERP\Helpers\ListagemPadrao.cs 23 25 ERP
SQL工作:
var lista =
from a in db.Usuario.AsQueryable()
.OrderBy(aOrderna + " " + aOrdenaTipo)
.Skip(aIniciarNoRegistro)
.Take(aQtdeRegistro)
select new
{
a.UsuarioID,
a.Nome,
a.Login,
a.Email
};
SQL 不起作用:
var lista =
from a in db.Usuario.AsQueryable()
join b in db.UsuarioAcesso.AsQueryable() on a.UsuarioID equals b.UsuarioID
.OrderBy(aOrderna + " " + aOrdenaTipo)
.Skip(aIniciarNoRegistro)
.Take(aQtdeRegistro)
select new
{
a.UsuarioID,
a.Nome,
a.Login,
a.Email
};