DynamicLinq C# not working in join

c# dynamic-linq join linq select

Question

I am using in my C # projects DynamicLinq.

When I do a simple select using "order by", "skip", etc. works perfectly.

But if you do join restona simple error:

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

SQL not work:

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 solution to the problem was:

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 do not understand why it works well .... tks from help

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