Group join- Index was outside the bounds of the array

Posts   
 
    
siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 15-Mar-2013 17:08:24   

Hi all,

Apologies, I'm relatively new using Linq with LLBLGen. I've looked through the docs but can't find a solution to this.

What I'm trying to do is a Group Join between two tables with a one-to-many relationship:



            var rows = (from u in _db.User
                       join ucd in _db.UserCalendarDay on u.Id equals ucd.UserId into days
                       select new 
                       {
                           UserId = u.Id,
                           DayData = days
                       }).ToList();


I've simplified this down a lot to a point where I still get the error. I realise there's an easier way to do what the code above does.

I want DayData to contain a list of the child UserCalendarDay objects. When I run the code above I get:

"Index was outside the bounds of the array."

To accomplish the group join I'm just following the info at http://msdn.microsoft.com/en-gb/library/bb311040.aspx

There are definitely rows in the UserCalendarDay table which match those in the User table but even if there weren't I wouldn't expect it to error>

Stack trace:



[IndexOutOfRangeException: Index was outside the bounds of the array.]
   lambda_method(Closure , Object[] , Int32[] ) +216
   SD.LLBLGen.Pro.LinqSupportClasses.DataProjectorToObjectList`1.AddRowToResults(IList projectors, Object[] rawProjectionResult) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\DataProjectorToObjectList.cs:120
   SD.LLBLGen.Pro.LinqSupportClasses.DataProjectorToObjectList`1.SD.LLBLGen.Pro.ORMSupportClasses.IGeneralDataProjector.AddProjectionResultToContainer(List`1 valueProjectors, Object[] rawProjectionResult) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\DataProjectorToObjectList.cs:103
   SD.LLBLGen.Pro.ORMSupportClasses.ProjectionUtils.FetchProjectionFromReader(List`1 valueProjectors, IGeneralDataProjector projector, IDataReader datasource, Int32 maxNumberOfItemsToReturn, Int32 pageNumber, Int32 pageSize, Boolean clientSideLimitation, Boolean clientSideDistinctFiltering, Boolean clientSidePaging, UniqueList`1 stringCache, Dictionary`2 typeConvertersToRun) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Projection\ProjectionUtils.cs:202
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List`1 valueProjectors, IGeneralDataProjector projector, ITransaction transactionToUse, IRetrievalQuery queryToExecute, Dictionary`2 typeConvertersToRun) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\DaoBase.cs:675
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List`1 valueProjectors, IGeneralDataProjector projector, ITransaction transactionToUse, IEntityFields fields, IPredicateExpression filter, IRelationCollection relations, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IGroupByCollection groupByClause, Boolean allowDuplicates, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\DaoBase.cs:635
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider.ExecuteValueListProjection(QueryExpression toExecute) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProvider.cs:162
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:264
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:93
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProProviderBase.cs:700
   SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\LinqSupportClasses\LLBLGenProQuery.cs:162
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +315
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   Khronos.BLL.Calendar.CalendarService.GetCalendarData(List`1 viewableUsers, CalendarFilterCriteria filter, DateTime startDate, DateTime endTime, Int32 startRecord, Int32 pageSize) in C:\LocalCopies2010\WebApps\Khronos\trunk\Khronos.BLL\Calendar\CalendarService.cs:37
   Khronos.WebApp.TestStuff.CalendarTest.OnLoad(EventArgs e) in C:\LocalCopies2010\WebApps\Khronos\trunk\Khronos.WebApp\TestStuff\CalendarTest.aspx.cs:43
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207


Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 15-Mar-2013 22:34:23   

please try the latest 3.5 build. You didn't say whether you use that one or not.

Frans Bouma | Lead developer LLBLGen Pro
siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 18-Mar-2013 11:11:34   

Ok, I think mine is probably an older build. I'll install the new one and see if it fixes the problem.

Cheers.