Help. I'm getting an "Object reference not set an instance of an object" error when doing a FetchEntityCollection in adapter. Here's my code. Where did I blow it?
EntityCollection cal = new EntityCollection(new CalendarEntityFactory());
IRelationPredicateBucket calF = new RelationPredicateBucket();
calF.Relations.Add(CalendarEntity.Relations.SpecialDayEntityUsingCalDate);
calF.PredicateExpression.Add(PredicateFactory.Between(CalendarFieldIndex.CalDate,startDate,endDate));
calF.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(SpecialDayFieldIndex.LocId, ComparisonOperator.Equal,542));
calF.Relations.Add(SpecialDayEntity.Relations.CdSpecialDayEntityUsingCode);
calF.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue( CdSpecialDayFieldIndex.IsInstructionDay,ComparisonOperator.Equal,0));
IPrefetchPath2 spcP = new PrefetchPath2((int)EntityType.SpecialDayEntity);
spcP.Add(SpecialDayEntity.PrefetchPathCdSpecialDay);
ISortExpression calS = new SortExpression(SortClauseFactory.Create(CalendarFieldIndex.CalDate,SortOperator.Ascending));
using (DataAccessAdapter da = new DataAccessAdapter())
{
da.FetchEntityCollection(cal,calF,0,calS,spcP);
}
...and here's the stack trace
[NullReferenceException: Object reference not set to an instance of an object.]
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.MergeNormal(IEntityCollection2 rootEntities, IPrefetchPathElement2 currentElement, Boolean rootEntitiesArePkSide) in c:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries 1.0.2004.2\ORMSupportClasses\DataAccessAdapterBase.cs:3594
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchPrefetchPath(IEntityCollection2 rootEntities, IRelationPredicateBucket filterBucket, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath) in c:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries 1.0.2004.2\ORMSupportClasses\DataAccessAdapterBase.cs:3539
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath) in c:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries 1.0.2004.2\ORMSupportClasses\DataAccessAdapterBase.cs:1848
HLPUSD.SMART.BLL.StudentManager.GetReleaseDayList(String stuID, DateTime startDate, DateTime endDate) in g:\documents and settings\njdevore\my documents\visual studio projects\smartbll\studentmanager.cs:303
HLPUSD.SMART.ParentPortal.stuHome.fetchReleaseList(StudentManager stuMgr) in g:\inetpub\wwwroot\smartparentportal\stuhome.aspx.cs:107
HLPUSD.SMART.ParentPortal.stuHome.fetchStatistics(StudentManager stuMgr) in g:\inetpub\wwwroot\smartparentportal\stuhome.aspx.cs:71
HLPUSD.SMART.ParentPortal.stuHome.Page_Load(Object sender, EventArgs e) in g:\inetpub\wwwroot\smartparentportal\stuhome.aspx.cs:38
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
I have my Calendar table which holds one record for every day of the school year. The SpecialDay table holds all the holidays for each LocID. So Calendar is joined to SpecialDay via CalDate and SpecialDay is joined to the code set CdSpecialDay so that I can know if it is a holiday or a school release day. Anyway, what am I missing?