views:

16

answers:

0

Hello, I'm trying to execute this linq2nhibernate query:

from e in endContratoRepository.GetAll()
                                            where e.Contrato.idContrato == contrato.idContrato &&
                                            e.Volume.idVolume == contratoVolume.Volume.idVolume &&
                                            e.flgAtivo
                                            group e by new { e.webDepartamento.idDepartamento, e.webCentroCusto.idCentroCusto }
                                                into grp orderby grp.Count()
                                                select new
                                                {
                                                    total = grp.Count(),
                                                    idDepartamento = grp.Key.idDepartamento,
                                                    idCentroCusto = grp.Key.idCentroCusto
                                                };

but I'm getting a null reference exception... the query without the orderby grp.Count() works fine.

thanks.