EntitySession exception from Aggregate Functions MAX()

Mar 29, 2010 at 12:31 AM

DatabaseEntityWithAttributes db = new DatabaseEntityWithAttributes(provider);
var p = db.CN_ATTIVITA.Max(q=> q.ID_ATTIVITA);
// OK p = max value.

DatabaseEntitySession des = new DatabaseEntitySession(provider);
var pppp = des.DES_CN_ATTIVITA_TIPOLOGIA.Max(ww => ww.ID_TIPOLOGIA_ATTIVITA);
// exception GetTable() entity is null;

EXCEPTION HERE:

protected ISessionTable GetTable(MappingEntity entity)
{
    // EXCEPTIN entity is null;
    ISessionTable table;

    if (!this.tables.TryGetValue(entity, out table))
    {
        table = this.CreateTable(entity);
        this.tables.Add(entity, table);
    }
    return table;
}