DynamicLinq C# not working in join

c# dynamic-linq join linq select

Question

I use DynamicLinq in my C# applications.

It works great when I do a straightforward choose using "order by," "skip," etc.

But if you do join Reston, here's a quick mistake:

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

the SQL work

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
      };   

Not working 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
      };
1
0
4/25/2013 2:40:02 PM

Popular Answer

The issue was resolved by:

var lista =
  (from a in db.Usuario.AsQueryable()
  join b in db.UsuarioAcesso.AsQueryable() on a.UsuarioID equals b.UsuarioID   
  select new
  {
      a.UsuarioID,
      a.Nome,
      a.Login,
      a.Email
  })
  .OrderBy(aOrderna + " " + aOrdenaTipo)
  .Skip(aIniciarNoRegistro)
  .Take(aQtdeRegistro);

But I don't know why it works so effectively. Thanks for the advice.

0
4/25/2013 4:41:39 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow