Prefetch null reference exception

Posts   
 
    
Posts: 1
Joined: 13-Nov-2009
# Posted on: 13-Nov-2009 00:18:23   

Hi, This is my first battle with Linq to LLBL and Linq in general. Everything seems to be working until I add the following prefetch to my query.

var query = (from r in metaData.Request join s in metaData.RequestStatus on r.RequestId equals s.RequestId let q1 = (from s2 in metaData.RequestStatus where r.RequestId == s2.RequestId select s2.CreateDate).Max() where s.CreateDate == q1 && s.Status == "Complete" select r).WithPath(requestPath => requestPath .Prefetch<UserEntity>(r => r.Requester) );

Ultimately, I need a much more complex prefetch, but I started here and failed - in an epic fashion.

Any help would be greatly appreciated.

Here is the stack trace. [NullReferenceException: Object reference not set to an instance of an object.] SD.LLBLGen.Pro.LinqSupportClasses.PrefetchPathAPI.PathElementCreator.CreateEntityCollectionAdapter() +32 SD.LLBLGen.Pro.LinqSupportClasses.PrefetchPathAPI.PathElementCreator.CreatePrefetchElement() +255 SD.LLBLGen.Pro.LinqSupportClasses.PrefetchPathAPI.PathEdgeRootParser1.CreatePathEdge(Type source, Type destination, String propertyName) +47 SD.LLBLGen.Pro.LinqSupportClasses.PrefetchPathAPI.PathEdgeRootParser1.ParseComplexPathSpecification(MemberExpression expression) +113 SD.LLBLGen.Pro.LinqSupportClasses.PrefetchPathAPI.PathEdgeRootParser1.Prefetch(Expression1 expression) +107 Dashboard.Data.EntityClasses.LookSeeSiteEntity.<GetAllClosedAppraisalRequestsWithinFiveDays>b__3(IPathEdgeRootParser1 requestPath) in D:\Team Foundation Projects\Dashboard\Branches\Development\LookSeeIntegration\Dashboard.Data\ClassExtensions\LookSeeSiteEntity.cs:145 SD.LLBLGen.Pro.LinqSupportClasses.QueryableExtensionMethods.WithPath(IQueryable1 source, Func`2 edgeSpecifierFunc) +110 Dashboard.Data.EntityClasses.LookSeeSiteEntity.GetAllClosedAppraisalRequestsWithinFiveDays(Boolean priority) in D:\Team Foundation Projects\Dashboard\Branches\Development\LookSeeIntegration\Dashboard.Data\ClassExtensions\LookSeeSiteEntity.cs:140 Dashboard.Data.EntityClasses.LookSeeSiteEntity.GetAppraisalRequestsByStatus(AppraisalRequestStatus status, ISortExpression sorter, Boolean priority) in D:\Team Foundation Projects\Dashboard\Branches\Development\LookSeeIntegration\Dashboard.Data\ClassExtensions\LookSeeSiteEntity.cs:72 Dashboard.Data.EntityClasses.LookSeeSiteEntity.GetAppraisalRequestsByStatuses(AppraisalRequestStatus[] statuses, ISortExpression sorter, Boolean priority) in D:\Team Foundation Projects\Dashboard\Branches\Development\LookSeeIntegration\Dashboard.Data\ClassExtensions\LookSeeSiteEntity.cs:41 Dashboard.Components.Helpers.PulseReportGuiHelper.GetAllLegacySitesByRequestStatus(AppraisalRequestStatus status, Boolean useCache, Boolean priority) +3199 Dashboard.Components.Helpers.PulseReportGuiHelper.GetAllLegacySitesByRequestStatus(AppraisalRequestStatus status, Boolean useCache) +46 Dashboard.Components.Helpers.CacheHelper.ClearPulseReportCache() +157 Dashboard.Web.UserControls.PulseReport.btnRefresh_Click(Object sender, EventArgs e) +32 System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Nov-2009 05:36:14   

Hi Rosie,

What is the exact sql query you want to reproduce? Also, please update to the latest runtime library version (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=12769).

David Elizondo | LLBLGen Support Team