I'm a total noob but I see that linq can save me a ton of code.
I am trying to sum up rows grouped by two fields:
Dim list = From A In mInvoiceHead.InvoiceRows Where A.PERIODE > 0 _
Group A By A.PERIODE, A.AAR _
Into Total = Sum(A.Amount) _
Select PERIODE, AAR, Total
When I execute the code i get the following error:
Value cannot be null.
Parameter name: source (System.Core)
at System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)
at ButikkdataNETWin.MDIParent1.TESTToolStripMenuItem_Click(Object sender, EventArgs e) in C:\DEVELOP\NET35\Butikkdata\ButikkdataNET.root\ButikkdataNETWin\MDIParent1.vb:line 1016
I have no idea what the problem is. Is the query constructed wrong or have I made a mistake designing the csla objects?
OK. I have found the source of the problem.
If I use CSLA 3.6.1 the code works fine and the query is returning the expected result.
If I use CSLA 3.8.2 i get the error: Value cannot be null. Parameter name: source (System.Core)
Can you confirm this and, if so, add it to the issues list?
I have tested this on CSLA 3.8.3 and found it not working.
Tested on CSLA 4.0.0 WORKING. But I had not planed to move to 4.0 just yet.
I have also found that if I convert BusinesstBase and BusinessListBase to ReadOnlyBase and ReadOnlyListBase the query is working. The objects I have used is from the ProjectTracker project.
Is no one using Linq in this way?
Rocky, what do you think?
In 3.8 you can force CSLA to bypass its custom query provider by adding ToList() to your original list:
var x = from r in _myList.ToList() ...
The reason you don't see the problem in CSLA 4 is that I removed the custom query provider - it has proven to be far more trouble than it is worth...
So by using .ToList() or CSLA 4, your query will not return a LinqBindingList - it will return a standard IEnumerable<T>.
In CSLA 4 if you want a synced view, you need to use the ToSyncList() extension method on the result of the query.
Copyright (c) Marimer LLC