Syncfusion WPF Grid and CSLA Linq implementation..

Syncfusion WPF Grid and CSLA Linq implementation..

Old forum URL: forums.lhotka.net/forums/t/8056.aspx


Vinodonly posted on Saturday, November 28, 2009

I requested a Syncfusion wpf grid sample using csla from their support team.. Databinding and other stuff seems to work but when we click on column headers which provides sorting or other filtering part then exceptions are thrown. After discussing with them I got following replies and I wanted to cross verify this thing here..

REPLY 3
=====
I already checked the default support for LINQ in CSLA, The LINQ providers implemented in CSLA is not proper, It is more a workaround implementation done, I have checked the implementation in reflector (ClsaQueryProvider class), It does a dynamic invocation of methods in the Enumerable class (the LINQ provider implementation for IEnumerable types thru Enumerable class). The way LINQ providers are implemented inside the .NET Framework has to be followed to make the patterns work.

Reply 2
=====

We will fix this issue once the CSLA has strong support for LINQ, If you had checked the sample you can see it clearly, there is a NullRef exception getting thrown with the CSLA Framework.

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Csla"
StackTrace:
at Csla.LinqBindingList`1.d__0.MoveNext()
at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Fahad\Desktop\ConsoleApplication1_a571a842\ConsoleApplication1\Program.cs:line 64
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

I think they have some iterator with IBindingList implemented wrongly. In the sample, we have attached the Csla.dll assembly that we currently downloaded from that website, If there is any other source code that fixes this issue, then we would use that and prepare a sample. Without the LINQ expressions getting executed, It is pretty hard to change the architecture now, and not quite possible to do so too.

Reply 1
=====

We are pretty sure that CSLA's implementation of LINQ enuemrators are causing exceptions. You can check out the sample that we have already posted, If you look at the foreach statement in this below code (from the sample),

var orders = new Order();
var sortByName = orders.AsQueryable().OrderBy("Name");
foreach (DataEdit o in sortByName)
{
Console.WriteLine("{0} - Name", o.Name);
}

Console.ReadKey(true);

It throws an exception with some CSLABindingList enumerator. I am pretty sure that the implementation of OrderBy clause for all IQuerable extensions is not implemented properly. We cannot proceed further if there an issue with this other ORM framework, also, we do not intend to change the LINQ based approach.

We also dynamically generate LINQ expressions for any IEnumerable or IQueryable, In the sample we have some extension methods copied over from our library for testing. Let us know your results on testing CSLA with LINQ.

RockfordLhotka replied on Saturday, November 28, 2009

This may have to do with L2C.

But with other datagrid controls the issue is not about L2C, it is about the fact that WPF doesn't really like IBindingList, which is the current base of CSLA collection types. This issue has been discussed at substantial length in a couple other threads, and is perhaps the biggest breaking change I'll be making in version 4.0 - to change the collection types all over to ObservableCollection<T> as a base so they work correctly with WPF.

(I say 'breaking change', but in reality it should only break Windows Forms users - everyone else should (generally speaking) find that their code keeps working unless they are manually interacting with the IBindingList base interface)

Vinodonly replied on Sunday, November 29, 2009

Actually I'm using mix of wpf and winforms..

does this means that csla 4.0 onwards will not work for winforms or will there be a alternative to support both..

RockfordLhotka replied on Sunday, November 29, 2009

I suppose I need to add this to the FAQ, since the answer is buried in other
threads.

CSLA .NET 1.x to 3.x supported Windows Forms directly through the base
collection types. CSLA .NET 3.x partially supported WPF, but WPF requires a
different collection base class for full support, so there's no way to fully
support both Windows Forms and WPF.

CSLA .NET 4.0 will fully support WPF through the base collection types. This
means the base collection types won't work well with Windows Forms. I plan
to copy the 3.8 base collection types to the Csla.Windows namespace (or just
rename them) so Windows Forms will continue to be fully supported - you just
need to pick the correct base collection types depending on whether you are
using Windows Forms or not.

CSLA .NET for Silverlight already uses the correct base class for the base
collection types, so you can look there to see what CSLA .NET 4.0 will look
like. The SL types offer almost complete backward compatibility, but work
with XAML binding, not Windows Forms binding.

Copyright (c) Marimer LLC