DAL or BOL? Can someone clarify?

N

Nemisis

Hi all,

I was wondering about where this code should go.

Basically i have several tables in my database, when i add a row to a
particular table, i will need to also add other entries in other
tables.

I would consider this to be code that should be in the BOL? Am i right
in thinking that?

The same if i was deleting records in the database, if a record is
deleted from one table, i need to also delete other entries in other
tables, BOL or DAL?

My database is setup with relationships so SQL will report errors on
foreign keys that cannot be deleted, so this is the one reason why i
thought it may go in the DAL, but then again, it is a business rule,
that if one row is deleted in one table, other row in other tables
should be deleted.

Can someone please let me know, or pass an article for me to read.

Cheers
 
M

Mark Rae

I was wondering about where this code should go.

Basically i have several tables in my database, when i add a row to a
particular table, i will need to also add other entries in other
tables.

I would consider this to be code that should be in the BOL? Am i right
in thinking that?

The same if i was deleting records in the database, if a record is
deleted from one table, i need to also delete other entries in other
tables, BOL or DAL?

My database is setup with relationships so SQL will report errors on
foreign keys that cannot be deleted, so this is the one reason why i
thought it may go in the DAL, but then again, it is a business rule,
that if one row is deleted in one table, other row in other tables
should be deleted.

Can someone please let me know, or pass an article for me to read.

I would say that in this case it's a combination of both BOL and DAL,
depending on how your DAL is constructed.

E.g. in my standard DAL I have an ExecuteInTransaction method which takes
multiple database writes and executes them in an explicit transaction,
returning a collection of the return values of each individual write plus an
overall bool of whether the transaction was committed or rolled back.

I would therefore construct a method or even an entire class in my BOL which
would assemble the various SQL actions and then pass them to the
ExecuteInTransaction method in my DAL.
 
N

Nemisis

Mark said:
I would say that in this case it's a combination of both BOL and DAL,
depending on how your DAL is constructed.

E.g. in my standard DAL I have an ExecuteInTransaction method which takes
multiple database writes and executes them in an explicit transaction,
returning a collection of the return values of each individual write plus an
overall bool of whether the transaction was committed or rolled back.

I would therefore construct a method or even an entire class in my BOL which
would assemble the various SQL actions and then pass them to the
ExecuteInTransaction method in my DAL.

Mark,

Thanks for this, i have got my DAL and BOL that both accept a
IDBTransaction property, so i think i can handle it just as you said.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top