Dan
Dan

Reputation: 11

SubSonic - How can i create my business logic layer

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

Upvotes: 1

Views: 212

Answers (1)

quentin-starin
quentin-starin

Reputation: 26628

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.

Upvotes: 1

Related Questions