views:

47

answers:

1

Hi Guys

Im new to subsonic and generally this was of programming, i usually develop from a rad perspective so using the visual studio dataset designer, but i wanted to start looking at developing n teir approach.

Ive never used a business logic layer, (naughy) normally my code behind takes care of validation so to speak aswell as general page level validation.

How can i generate my business logic, do i create a partial class of one of my classes and then add the business logic into this? and how would this look? just so i have an idea.

Any exmaples or advice would be greatly appreciated.

Thanks

Dan

+1  A: 

The big gotchya with SubSonic is that it generates classes from database tables, there is a 1-to-1 correspondence between the two. That makes the classes SubSonic generates quite unsuitable for use as business objects, because it would tie your business layer very directly to your database structure. This is a bad thing (in nearly all scenarios that come to my mind, anyway).

SubSonic is a query tool and little more. It most certainly is not an ORM.

With that in mind, I believe the correct way to create a Business Logic Layer is to write your own business classes, and write Repository classes to manage loading and storing the data. But use SubSonic only internally to the Repository classes to handle the actual persisting of your data to the database.

If you use the SubSonic generated classes throughout your project you will find you are most likely doing it wrong, and the first significant change to your DB schema will illustrate that nicely (or .. not nicely).

In fact, I would recommend quickly moving into learning a real ORM like NHibernate or Entity Framework. They bring you much farther down the Happy Path, whereas SubSonic still requires one to do much of the Data Layer implementation themselves.

qstarin
Hi Qstarin, maybe my question wasnt to clear, basically i want to create some business logic to peform validation based on, i know i can do this in partial classes based on the originally generated class but i wanted to know how / where to implement this.Are there custom events like before insert, before delet etc that i can intercept and stop if validation or business rules arent met??
Dan