Using O/RM with CSLA.NET

Using O/RM with CSLA.NET

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


Spaz80 posted on Sunday, September 30, 2007

Hello

I´m new CSLA user and looking into integrating CSLA.NET with a ORM tool...like LINQtoSQL...

Anybody out there who has any experience to pass on in this area?

Cheers

Spaz

RockfordLhotka replied on Sunday, September 30, 2007

The most widely used ORM tool (that I'm aware of) is nHibernate, and there are numerous threads on this forum on the use of nHibernate.

You should also look at the DeepData sample app from www.lhotka.net/cslanet, as it illustrates some good techniques for working with externalized data access layers. Specifically, when working with an ORM, look at how it uses data transfer objects (DTOs).

That's the thing with an ORM - it will produce "entity objects". That's just a fancy way of saying DTO, and it is important to realize that those entity objects are not the same as business objects.

It all comes down to responsibility. The responsibility of an entity object is to provide access to shaped data, backed by a data store. The responsibility of a business object flows from your use case, and the responsibility is all about business behaviors.

Entity objects get their responsibility primarily from technology requirements. Only their shape is influenced by business requirements.

Business objects get their responsibility primarily from business requirements. Only their secondary behaviors (like data binding, n-level undo, etc) are influenced by technology requirements.

If you are going to use an ORM - and I expect most of us will once DLINQ and/or ADO.NET EF are options - that's awesome! But these technologies merely replace the use of raw ADO.NET, and they sit naturally behind your actual business layer, which is composed of business objects.

Copyright (c) Marimer LLC