I've run into some differing runtime troubles regarding LINQ syntax behaving differently from SILVERLIGHT to WPF. Because I rarely code in WPF, I at first thought this was due to the differences between the CLRs, but now I'm wondering if it's due to the differences in Csla to CslaLight...
First, I posted on the Silverlight forums here:
http://forums.silverlight.net/forums/t/128859.aspx
Is it possible that there's a difference in these two frameworks (Csla and CslaLight) instead?
I'm looking into it, but is there a difference in the way the CslaQueryProvider implements IQueryProvider in CslaLight vs. Csla?
EDIT: I see now that CslaLight doesn't even have CslaQueryProvider.
Confirmed that this is related to CSLA only (atleast somehow)
the following syntax works fine and does not throw an arguement null exception in WPF and returns an empty IEnumerable list, whereas performing the same query on a BusinessListBase does throw an ArgumentNullException
var
testList = new List<string>() { }; var testQuery = from s in testList where s.Contains("test for s being null") select s;Can anyone help me understand what I'm seeing here? It really doesn't make sense to me that I see this behavior from Csla object when porting from Silverlight and WPF
There is a difference in CSLA - in that CSLA .NET for Windows includes LINQ to CSLA and CSLA .NET for Silverlight does not.
In other words, CSLA .NET doesn't do anything with LINQ on the Silverlight platform - so the behaviour you see there is whatever LINQ to Objects does for any list or collection.
Thanks for the response. I kind of presumed this might be the case, but it was certainly not immediately obvious. Now I understand why my app is running so coarse due to these LINQ queries! Any possibility of a LINQ to CSLA for SL?
Further, though I'm no expert on the subject, it seems like throwing exceptions with the following code examples breaks code. IMHO of course. If you have any suggestions to avoid these problems, I'm all ears.
1. For example the following syntax. If the where clause fails to return anything, in SILVERLIGHT (w/ LINQ to object) tmp will be assigned to null. However, in LINQ to CSLA, the LINQ query throws an ArgumentNullException if the where clause can't find anything.
var tmp =fromsomething in this.SomeList where something.Value == someOtherValueselect something;
(Workaround) The syntax below works in both environments by using a Where clause with a lambda expression:
var tmp =fromsomething in this.SomeList.Where(s => s.Value == someOtherValue) select something;
2. Below assigns null to tmp in LINQ to objects if the query is null, but throws an ArgumentNullException in WPF (LINQ to CSLA) if the query returns null.
var tmp =
(from something in this.SomeList.Where(s => s.Value == someOtherValue) select something).FirstOrDefault();
Aaron Erickson:Indeed, looks like you found a behavior difference which would be a bug. I expect to work on a fix during VSLive this week.
Just curious, was this resolved?
Copyright (c) Marimer LLC