I have this valid query (in .Net4.0) that gets the still-open invoices:
Dim dinvs = AcStudentInvoiceDetails _
.GroupBy(Function(di) di.InvoiceID) _
.Select(Function(di2) New With { _
.InvoiceID = di2.Key, _
.DebitSum = di2.Sum(Function(di3) di3.Debit), _
.CreditSum = di2.Sum(Function(di3) di3.Credit) }) _
.Where(Function(dd) dd.DebitSum > dd.CreditSum)
Dim invs = From i In AcStudentInvoices _
Join di In dinvs On i.ID Equals di.InvoiceID _
Select i
I tested this query on LinqPad, and it gets correct results, but LinqPad works on .Net 4.0, and my project works on .Net3.5, the error is that we have an anonymous object and in .Net3.5, Where can’t work with anonymous objects.
I tried to create a strongly-typed class instead of the anonymous object but I got lost in the syntax of Linq, so I need an equivalent for this query in .Net3.5
Error text excerpt:
Overload resolution failed because no accessible ‘Where’ can be called with these arguments:
Extension method ‘Public Function Where(predicate As System.Linq.Expressions.Expression(Of System.Func(Of <anonymous type>, Integer, Boolean))) As System.Linq.IQueryable(Of <anonymous type>)’ defined in ‘System.Linq.Queryable’: Nested function does not have the same signature as delegate ‘System.Func(Of <anonymous type>, Integer, Boolean)’…
You should be able to do this with a strong type
Which Makes your query like this,