Jed
Jed

Reputation: 315

group by in linq to llblgen

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.

Upvotes: 1

Views: 1336

Answers (1)

Frans Bouma
Frans Bouma

Reputation: 8357

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

Upvotes: 2

Related Questions