What about the ADO.NET Entity Framework and the Linq project ?

What about the ADO.NET Entity Framework and the Linq project ?

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


AAKLebanon posted on Wednesday, February 07, 2007

I was wondering about the the ADO.NET Entity Framework technology from microsoft(the new version of Ado.Net) and the Linq project, is compatible with CSLA ?

if anyone has any idea, please let's me share it !!

ajj3085 replied on Wednesday, February 07, 2007

Check out Rocky's blog; he's posted about this serveral times.

RockfordLhotka replied on Wednesday, February 07, 2007

They are totally compatible, but it is important to remember what they are for.

Both ADO.NET EF and LINQ work with entity objects - objects designed primarily as data containers. These technologies are all about making it an easy and intuitive process to get data into and out of databases (or other data stores) into entity objects, and then to reshape those entity objects in memory.

CSLA .NET is all about creating business objects - objects designed primarily around the responsibilities and behaviors defined by a business use case. It is all about making it easy to build use case-derived objects that have business logic, validaiton rules and authorization rules. Additionally, CSLA .NET helps create objects that support a rich range of UI supporting behaviors, such as data binding and n-level undo.

It is equally important to remember what these technologies are not.

ADO.NET EF and LINQ are not well-suited to creating a rich business layer. While it is technically possible to use them in this manner, it is already clear that the process will be very painful for anything but the most trivial of applications. This is because the resulting entity objects are data-centric, and don't easily match up to business use cases - at least not in any way that makes any embedded business logic maintainable or easily reusable.

CSLA .NET is not an object-relational mapping technology. I have very specifically avoided ORM concepts in the framework, in the hopes that someone (like Microsoft) would eventually provide an elegant and productive solution to the problem. Obviously solutions do exist today: raw ADO.NET, , the DAAB, nHibernate, Paul Wilson's ORM mapper, LLBLgen and more. Many people use these various technologies behind CSLA .NET, and that's awesome.

So looking forward, I see a bright future. One where the DataPortal_XYZ methods either directly make use of ADO.NET EF and LINQ, or call a data access layer (DAL) that makes use of those technologies to build and return entity objects.

Either way, you can envision this future where the DP_XYZ methods primarily interact with entity objects, deferring all the actual persistence work off to EF/LINQ code. If Microsoft lives up to the promise with EF and LINQ, this model should seriously reduce the complexity of data access, resulting in more developer productivity - giving us more time to focus on the important stuff: object-oriented design Wink [;)]

Patrick replied on Friday, February 08, 2008

RockfordLhotka:
Either way, you can envision this future where the DP_XYZ methods primarily interact with entity objects, deferring all the actual persistence work off to EF/LINQ code. If Microsoft lives up to the promise with EF and LINQ, this model should seriously reduce the complexity of data access, resulting in more developer productivity - giving us more time to focus on the important stuff: object-oriented design Wink [;)]

Hi,

I was wondering if you Rocky or anyone else has attempted to use CSLA.NET with ADO.NET EF as the DAL? Are there any plans for CSLA.NET 3.5 regarding EF?

It seems quite straight forward for selects but more challenging for updates, inserts etc. because of the EF DataContext.

Thanks for your feedback, Smile [:)]
Patrick

PS: Here are some helpful articles on the topic http://west-wind.com/weblog/

Patrick replied on Friday, February 08, 2008

This article on the Entity Framework EntityBag might contain a lot of helpful ideas on how to make EF work with CSLA.NET.

The strategy I adopted for EntityBag is to create a DataContract serializable object which will effectively transmit an entire ObjectStateManager ......  When it’s time to persist the changes, the EntityBag can be serialized back to the mid-tier and the updated entity graph along with all original values can be reconstructed into a mid-tier context which will then be used to save the changes to the DB.


http://code.msdn.microsoft.com/entitybag/

mcsean replied on Friday, August 29, 2008

Yes Patrick you are correct. EF handles the relationship between objects as well, which seems to me an overlap to CSLA framework. Rocky said that he'd had at least rewritten the CSLA framework 4 times, and I wonder if he would do that again or create a new version just for EF. At the meantime, I am waiting for his new book, cause I got very confused to these 2 frameworks.

Cheers

 

Copyright (c) Marimer LLC