This runs fine now:
var items = from item in metaData.Item
select new
{
item.Id,
item.Description,
QtyInStock = item.Stock.Where(s => s.WarehouseId == "whs").Sum(s => s.Quantity),
QtyInbound = item.InboundLine.Where(il => il.WarehouseId == "whs").Sum(il => il.Quantity) ?? 0,
QtyOutbound = item.OutboundLine.Where(ol => ol.WarehouseId == "whs").Sum(ol => ol.Quantity) ?? 0
} into result
where result.QtyInStock > 0
select result;
But this
var items = (from item in metaData.Item
select new
{
item.Id,
item.Description,
QtyInStock = item.Stock.Where(s => s.WarehouseId == "whs").Sum(s => s.Quantity),
QtyInbound = item.InboundLine.Where(il => il.WarehouseId == "whs").Sum(il => il.Quantity) ?? 0,
QtyOutbound = item.OutboundLine.Where(ol => ol.WarehouseId == "whs").Sum(ol => ol.Quantity) ?? 0
} into result
where result.QtyInStock > 0
select result).TakePage(1,5);
results in this exception
Onverwerkte uitzondering: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryConstructionException: Internal error: QueryExpression of non-entity type without projection encountered without prior source with projection.
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.CreateProjectionForQueryIfNoProjectionAvailable(QueryExpression toExecute)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery1.Execute()
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery
1.System.Collections.IEnumerable.GetEnumerator()
bij ObjectDumper.WriteObject(String prefix, Object o) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 62
bij ObjectDumper.Write(Object o, Int32 depth, TextWriter log) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 21
bij ObjectDumper.Write(Object o, Int32 depth) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 15
bij ObjectDumper.Write(Object o) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 11
bij LLBLGenPro.Program.Main(String[] args) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\Program.cs:regel 31
After eliminating the Where clause this runs fine again
var items = (from item in metaData.Item
select new
{
item.Id,
item.Description,
QtyInStock = item.Stock.Where(s => s.WarehouseId == "whs").Sum(s => s.Quantity),
QtyInbound = item.InboundLine.Where(il => il.WarehouseId == "whs").Sum(il => il.Quantity) ?? 0,
QtyOutbound = item.OutboundLine.Where(ol => ol.WarehouseId == "whs").Sum(ol => ol.Quantity) ?? 0
} into result
//where result.QtyInStock > 0
select result).TakePage(1,5);
but taking the second page with .TakePage(2,5) results in this exception
Onverwerkte uitzondering: System.MissingMethodException: Constructor voor type <>f__AnonymousType05[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, P
ublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.0.
0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is niet gevonden.
bij System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
bij System.Activator.CreateInstance(Type type, Object[] args)
bij SD.LLBLGen.Pro.ORMSupportClasses.DataProjectorToCustomClass
1.CreateNewInstance(List1 ctorArguments)
bij SD.LLBLGen.Pro.ORMSupportClasses.DataProjectorToCustomClass
1.AddProjectionResultToContainer(IList projectors, Object[] rawProjectionResult)
bij SD.LLBLGen.Pro.ORMSupportClasses.DataProjectorToCustomClass1.SD.LLBLGen.Pro. ORMSupportClasses.IGeneralDataProjector.AddProjectionResultToContainer(List
1 valueProjectors, Object[] rawProjectionResult)
bij SD.LLBLGen.Pro.ORMSupportClasses.ProjectionUtils.FetchProjectionFromReader(List1 valueProjectors, IGeneralDataProjector projector, IDataReader datasource, Int32 maxNumberOfItemsToReturn, Int32 pageNumber, Int32 pageSize, Boolean clientSideLimitati
on, Boolean clientSideDistinctFiltering, Boolean clientSidePaging)
bij SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List
1 valueProjectors, IGeneralDataProjector projector, ITransaction transactionToUse, IRetrievalQuery queryToExecute)
bij SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List1 valueProjectors, IGeneralDataProjector projector, ITransaction transactionToUse, IEntityFields fields, IPredicateExpression filter, IRelationCollection relations, Int32 maxNumberOfItem
sToReturn, ISortExpression sortClauses, IGroupByCollection groupByClause, Boolean allowDuplicates, Int32 pageNumber, Int32 pageSize)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider.ExecuteValueListProjection(QueryExpression toExecute)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery
1.Execute()
bij SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.IEnumerable.GetEnumerator()
bij ObjectDumper.WriteObject(String prefix, Object o) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 62
bij ObjectDumper.Write(Object o, Int32 depth, TextWriter log) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 21
bij ObjectDumper.Write(Object o, Int32 depth) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 15
bij ObjectDumper.Write(Object o) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\ObjectDumper.cs:regel 11
bij LLBLGenPro.Program.Main(String[] args) in G:\Projects\VS2008\Projects\Test\LLBLGenPro\LLBLGenPro\Program.cs:regel 31
After disabling QtyInbound and QtyOutbound this runs fine again
var items = (from item in metaData.Item
select new
{
item.Id,
item.Description,
QtyInStock = item.Stock.Where(s => s.WarehouseId == "whs").Sum(s => s.Quantity),
//QtyInbound = item.InboundLine.Where(il => il.WarehouseId == "whs").Sum(il => il.Quantity) ?? 0,
//QtyOutbound = item.OutboundLine.Where(ol => ol.WarehouseId == "whs").Sum(ol => ol.Quantity) ?? 0
} into result
//where result.QtyInStock > 0
select result).TakePage(2,5);
as does .TakePage(3,5) and so on.
I hope this illustrates enough for you to determine what is causing the exceptions.
Thanks