Dynamic List Counts - Object Referent Not Set

Posts   
 
    
shware
User
Posts: 23
Joined: 14-May-2007
# Posted on: 17-May-2008 00:50:36   

Hi,

Using the 12 May 2008 Build of 2.6 Beta.

The following query against the Northwind database:


            var customers = (from c in metaData.Customer
                             join o in metaData.Order on c.CustomerId equals o.CustomerId
                             select new { CustomerId = c.CustomerId, CompanyName = c.CompanyName, OrderId = o.OrderId, OrderDate = o.OrderDate });

            int cCount = customers.Count();

Generates the following error:


[NullReferenceException: Object reference not set to an instance of an object.]
   SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleAggregateExpression(AggregateExpression expressionToHandle) +144
   SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.GenericExpressionHandler.HandleExpression(Expression expressionToHandle) +203
   SD.LLBLGen.Pro.LinqSupportClasses.ExpressionHandlers.QueryExpressionBuilder.HandleExpression(Expression expressionToHandle) +118
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.HandleExpressionTree(Expression expression) +797
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression) +10
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression) +14
   System.Linq.Queryable.Count(IQueryable`1 source) +244
   _Default.Page_Load(Object sender, EventArgs e) +1063
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

The .Count() seems to be failing. If I use int cCount = customers.ToList().Count();, then it works but is not desirable as it executes 2 complete queries.

The .Count() function works on Linq statements which return EntityCollections.

Thanks,

Shawn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39873
Joined: 17-Aug-2003
# Posted on: 17-May-2008 09:51:27   

Will look into it. We made some major changes due to bugs in join/groupby etc. code in the last couple of days. I'll check it out to see if I can reproduce it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39873
Joined: 17-Aug-2003
# Posted on: 19-May-2008 16:28:43   

Reproduced...

(edit) fixed in next build.

Frans Bouma | Lead developer LLBLGen Pro