1

This is my statment

private IEnumerable<IGrouping<AccountEntity,AxsEntity>> GetAxsEntitiesForInvoicing(IDataAccessAdapter adapter)
{
    var metaData = new LinqMetaData(adapter);
    var query = from axsEntity in metaData.Axs
                join accountEntity in metaData.Account on axsEntity.AccountId equals accountEntity.AccountId
                where
                        (axsEntity.DateDeleted.HasValue? axsEntity.DateDeleted.Value<DateTime.Now:true) &&
                        (axsEntity.DateEnd == null || axsEntity.DateEnd > axsEntity.DateRenewal) &&
                        axsEntity.DateRenewal < RenewalDate // NONE INCLUSIVE DATE
                        group axsEntity by accountEntity into axsCol
                select axsCol;
    return query;

As soon as i try convert this to .ToList() it throws an error.

The type 'System.Linq.IQueryable1[[<>f__AnonymousType02[[Data.Rad.EntityClasses.AxsEntity, Data.Rad, Version=1.0.4125.30654, Culture=neutral, PublicKeyToken=null],[Data.Rad.EntityClasses.AccountEntity, Data.Rad, Version=1.0.4125.30654, Culture=neutral, PublicKeyToken=null]], Model.Rad, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' can't be converted to an entity type in any way. Did you use a let statement on a group by clause?

Is there anyway to do this. If I group by in memory it kills my computer.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Jed
  • 315
  • 1
  • 3
  • 8

1 Answers1

2

You can't use a groupby query to fetch entities, as groupby queries group data, and entities are fetched directly from tables.

Frans Bouma
  • 8,259
  • 1
  • 27
  • 28