This question is locked. New answers and comments are not allowed.
I'm having trouble with a LINQ query that joins on multiple tables.
This query throws a NullReferenceException when I try to iterate my addresses variable. The query works as expected and doesn't throw an exception if I remove "where p.PersonId == 1".
var addresses = from p in scope.Extent<CorePerson>()
join pa in scope.Extent<CorePersonAddress>() on p.PersonId equals pa.PersonId
join a in scope.Extent<CoreAddress>() on pa.AddressId equals a.AddressId
where p.PersonId == 1
select new
{
p.FirstName,
p.LastName,
a.StreetAddress1
};
foreach (var a in addresses)
{
Response.Write("<br />" + a.FirstName + " " + a.LastName + " " + a.StreetAddress1);
}
Stack Trace:
at Telerik.OpenAccess.Query.QueryContext.PerformDatabaseQuery(Type type, Expression expression, Int32& number, Boolean exec, Int32 numSkip, Int32 numTake, String aggregateMethod, ResultConverter& convert)
at Telerik.OpenAccess.Query.QueryContext.PerformDatabaseQueryMultiple[T](Expression expression)
at Telerik.OpenAccess.Query.ObjectScopeQuery`2.GetEnumerator()
at ArenaSL.Web.Test.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\calebt\My Documents\Test Projects\ArenaSL\ArenaSL.Web\Test.aspx.cs:line 55
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I can't map CorePersonAddress (a many-to-many) table as a Collection in OpenAccess because this is a many to many table that contains more data than just two ids and a sequence column.
I'm using the latest internal build (version 2009.3.1203.1) since I read some other posts that LINQ joins were improved in this version.
Any ideas? Thanks
This query throws a NullReferenceException when I try to iterate my addresses variable. The query works as expected and doesn't throw an exception if I remove "where p.PersonId == 1".
var addresses = from p in scope.Extent<CorePerson>()
join pa in scope.Extent<CorePersonAddress>() on p.PersonId equals pa.PersonId
join a in scope.Extent<CoreAddress>() on pa.AddressId equals a.AddressId
where p.PersonId == 1
select new
{
p.FirstName,
p.LastName,
a.StreetAddress1
};
foreach (var a in addresses)
{
Response.Write("<br />" + a.FirstName + " " + a.LastName + " " + a.StreetAddress1);
}
Stack Trace:
at Telerik.OpenAccess.Query.QueryContext.PerformDatabaseQuery(Type type, Expression expression, Int32& number, Boolean exec, Int32 numSkip, Int32 numTake, String aggregateMethod, ResultConverter& convert)
at Telerik.OpenAccess.Query.QueryContext.PerformDatabaseQueryMultiple[T](Expression expression)
at Telerik.OpenAccess.Query.ObjectScopeQuery`2.GetEnumerator()
at ArenaSL.Web.Test.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\calebt\My Documents\Test Projects\ArenaSL\ArenaSL.Web\Test.aspx.cs:line 55
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I can't map CorePersonAddress (a many-to-many) table as a Collection in OpenAccess because this is a many to many table that contains more data than just two ids and a sequence column.
I'm using the latest internal build (version 2009.3.1203.1) since I read some other posts that LINQ joins were improved in this version.
Any ideas? Thanks