Wednesday, February 07, 2007
« Help requested with weird ASP.NET custom... | Main | CSLA .NET 2.1.4 available »

I get a lot of questions about the new ADO.NET Entity Framework and LINQ and how these technologies interact with CSLA .NET. I've discussed this in a few other blog posts, but the question recently came up on the CSLA .NET forum and I thought I'd share my answer:

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 ;) .


Friday, February 09, 2007 11:11:39 AM (Central Standard Time, UTC-06:00)
There are a ton of ASP.NET against Oracle DB apps where, presumably, this will be a huge win, mostly due to Oracle's lack of support (at least historically) for stored procedures that return result sets (yes, you can do it, but it is very far from the path of least resistance, and thus, most people don't).

In other words, show me a .NET with Oracle project, and you will probably find a lot of DP_XYZ methods with stringbuilders accumulating SQL queries, some with proper parameters, some without. LINQ should be incredibly useful for that kind of project.
Saturday, February 10, 2007 3:20:15 AM (Central Standard Time, UTC-06:00)
Historically, Oracle is mostly used only with Java (nobody trust M$ if they are using Oracle). On Java platform OR mapping put the last nail on the coffin of stored procedure many years ago.

M$ screws up it again and again. Now ADOEF-ling at least makes it clear that .Net will follow the same route, no MUD anymore.

It is good for CSLA -- dataset has no future. However, I want to point out that this also means that stored procedures have no future either. Wake up! ADOEF-LING will finish stored procedures also.
Saturday, February 17, 2007 6:21:28 AM (Central Standard Time, UTC-06:00)
They're an interesting pairing. LINQ appears as a tool for those who wish to do more programming. EF looks like a tool for those who wish to do less. CSLA might be considered a tool that makes it easier either to do more (build a rich object model) or less (code-gen off a database schema and bind to a form) programming. Perhaps, Rocky, when asked about CSLA and EF, the focus is too-often on "doing less programming." I guess there is a general consensus that we should write as little code as possible. That's not my way. I guess I'm behind the times. When I think about LINQ, an inline DSL for queries, I think about how much more I could do with CSLA and .net. I'm empowered. I don't see why I can't have objects that perform set operations on data. I don't think my domain model will mind if some of my objects are editable collections of, say, construction sites, while others perform set operations on tables of data collected from sensors at any one of these sites. Some objects ARE tables. As for the EF, I'm not a software invalid. I can write my own ORM code. Even with EF, no matter how good it is, sooner or later I’m going to have to write it by hand.
Daniel Higgins
Sunday, February 18, 2007 12:42:01 AM (Central Standard Time, UTC-06:00)
OR mapping without caching stuff is actually easy.
The real impact of EF is its concept --with EF, dataset is finished.

I have been a no-dataset guy for many, many years. Recently, because of all those hypes, I gave dataset a serious try. I really did my due diligence, still, I am convinced that it is a piece of junk – I did not want to say that, because I was ashamed that I was so naïve, even after so many years …

I do not believe M$ can fix dataset anymore while they have started EF-- even it is just airware now.

That is the reason we can safely say that no dataset, long live custom class approach. Do not ever touch dataset anymore.

Sunday, February 18, 2007 12:02:05 PM (Central Standard Time, UTC-06:00)
Death to the dataset. :)

God help you when you have to do anything interesting with, say, a datarow (much less a whole dataset), such as serialize it to, say, a session state server or anything else similarly useful.

I still occasionally use datasets in .NET 2.0, but only in a very transient sense, such as passing in a datatable as a constructor to a domain object. EF should finally make them obsolete. RIP.
Wednesday, February 21, 2007 8:39:08 AM (Central Standard Time, UTC-06:00)
Hi Aaron,

Why not use Data Transfer Object ?
http://vikasnetdev.blogspot.com/2006/09/why-do-i-perfer-custom-collection-over.html

Anyway, Excellent LINQ Presentation at CNUG.
Comments are closed.