Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

I have talked about DLINQ and layering issue and I think SubSonic also suffers from the same problem. I used SubSonic during the long weekend and found out that it has rich entity class modal which also does the work of calling the DAL layer. Now, the question is that how can you make your class library portable. If you export your class library as a DLL you will also need to include the SubSonic.dll which is fine. But what if you want the users of your library to make use of your methods and NOT the SubSonic methods. This is going to be trouble because users can trigger any method on any table and do whatever they want using the SubSonic library.

I like the approach of making the thin entity classes only containing the defination of the entity and creating managers or repositories to handle the functional operations like Get, GetById and stuff. The code generators and OR mappers are leading towards the RAD style without any concepts of layering. Off course you can handle this problem by copy pasting the code into the required managers but then in my opinion this is just too much work.

Posted on Monday, November 26, 2007 6:09 AM | Back to top

Comments on this post: SubSonic and Layering Issue!!

# re: SubSonic and Layering Issue!!
Requesting Gravatar...
You could look at altering the templates so that all those methods are generated as private, and then extend the class via partial classes by adding your own public methods (could probably incorporate that into the templates as well?)

Left by D'Arcy from Winnipeg on Nov 26, 2007 6:49 AM

# re: SubSonic and Layering Issue!!
Requesting Gravatar...
I agree. That tends to be my issues with the Active Record pattern in general. AR makes a lot of things very simple, but at the same time, it breaks thinks like layering and separation of concerns.

At least with linq, you can make the context objects private, and you have some options there.

Jesse Foster | jf26028
Left by Jesse Foster on Nov 26, 2007 8:12 AM

# re: SubSonic and Layering Issue!!
Requesting Gravatar...
OK, so you are just describing the problem. What's the solution? IS there a solution?
Left by Zack Owens on Nov 26, 2007 8:50 AM

# re: SubSonic and Layering Issue!!
Requesting Gravatar...

Here is my humble opinion. The code generator should create two separate dlls. The first dll should be only entity classes lets say "Northwind.Entities". This contains classes like Northwind.Entities.Customer,Northwind.Entities.Category.

These will be very light entity classes and only contain the mappings and the relationships.

The other dll should be the Services or Managers dll. Something like:

Northwind.Services.CustomerService, Northwind.Services.CategoryService.

Each Service will have virtual methods which performs the functions as Add, Remove, GetById and stuff. The virtual behavior will allow us to override the methods.

PS: The entity classes should be partial classes.

Left by Mohammad Azam on Nov 26, 2007 8:58 AM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: