I've been working on an extension to the CSLA framework that ties it with Linq to SQL in order to reduce code.
My goal was to link the PropertyInfo with fetch and persist methods which will retrieve or store the property values when the object is saved or fetched . The base class has a Linq to SQL object as a type parameter so the fetch and persist lambdas in the overloaded RegisterProperty methods are strongly typed. Below, Customer is a Linq to SQL class.
In the data access portion of the code, you only need to implement two methods which defines the DataContext and the Linq query the fetch the row required. You don't need to load and save the values from Linq to SQL, it is already handled in the base class.
I've also created other base classes and I'm happy so far with the framework. My concern is that the classes are strongly tied to Linq to SQL, I don't know if I should attempt trying to make it work with entities and I think a separate version would be required. I don't have experience working on projects with Linq to SQL. Is it a ORM choice? I attempted to work with Entities but it doesn't play well with the schema I have to work with.
Maybe I should have stuck with code generation, but thats no fun and I wouldn't learn as much. But I fear later on, I'll have a maintenance problem on my hands.
Ideas and advice would be greatly appreciated.
Thanks.
Microsoft has made it pretty clear that their direction is EF, not L2S. But since L2S shipped as part of .NET, it falls under the standard service agreement, which means they'll basically keep it running and support it for 10 years, but it probably won't get enhanced, or be integrated into anything new or that sort of thing.
Hmmm. I'll look into entity in the future, but for now L2S works well and I don't need any of the features in entities. Hopefully, I could add entity support later on without breaking too much of my code. Designing frameworks is hard. Thanks Rocky.
hi almostchristian,
your approach looks very interesting.. is it possible for you to share more details/code on how this full thing is working..
Sure! I'd love to share my work. I let me prepare some samples and I'll share a link
You can download my code and a sample using the AdventureWorks sample database here http://cid-40804cef94254f69.skydrive.live.com/redir.aspx?resid=40804CEF94254F69!1357
I got it working on Silverlight once but then I did something and it broke. Silverlight is not a priority for me right now so if someone can provide a working example, please do. I need suggestions and criticism so I can improve my code.
I liked the whole idea of elminating the codegens and overall this looks quite intersting.. although linq to sql fact is also undeniable..
in any case, thanks for sharing.. i will get back with my comments after studying code..
Copyright (c) Marimer LLC