By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

Passing data - BUS to DAL to Param object?

P: n/a
First off this is a great reference for passing data between the Data Access
and Business Layers:
http://msdn.microsoft.com/library/de...rchPatPrac.asp

I use my own classes in the Business layer. I want to keep the Data Access
layer from requiring these classes so I tried passing a Datarow between the
layers and it seems to work good for me. Constructing the datarow in the
Class for an update statement and simply passing it up from the Data Access
layer for Loads.

Obviously, using this method I need to construct the DataRow in the class
and then parse it out in the Data Access layer to get it into the Parameters
object to run my Update stored procedure. I am using a XmlSchema file so I
know what the DataRow should look like in the Business layer.

I feel like I am mixing and matching technologies and missing an optimal
solution. My goal is to make the translation from a DataRow into the
Parameters object more dynamic. I don't want to have to change the DAL if I
do something like add a field.

Can anyone point me in the right direction to achieve this? I have very
limited XML experience but if that is the answer then I will happily adopt
it. If you need clarification on anything please email directly or simly
reply to the group.

TIA (Sorry for the length of the post, if you are still reading)

- Marc Castrechini
mc@merchantwarehouseREMOVETHIS.com
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Marc,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you have some confusion on how to
separate the business layer from data access layer.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

From me knowledge your design seems ok. Now you will share the xml file
which will descibe the datarow between the DAL and BL. When you add one
field into the the datarow, you will change the xmlfile, so that the DAL
and the BL will know the change. Also when you add one filed into the
datarow, will you also make some change to the DataBase, e.g. add a column
to one the table? If so I'd suggest you do not make two layer, since if you
change the database, your DAL usually need to be changed too.

I also suggest you do not use the concret field name to access the
according field in the dataset in the DAL, so that when you pass the
datarow from BL to DAL, you do not need to make change, you can use the
statement such as "For Each...... Next" or Column(i).

If you still have more detailed question on this issue, please feel free to
post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2

P: n/a
Marc,
If you are passing a DataRow to you Business Object, it sounds like the
Business Object is coupled to closely to the Data!

The framework that I like to use is based on Martin Fowler's book "Patterns
of Enterprise Application Architecture"
http://www.martinfowler.com/books.html#eaa Especially when Domain Objects
(aka Business Objects) are required, as Martin has a couple useful patterns
when DataSets themselves are more appropriate.

The framework I use with Domain Objects include the following patterns:
Domain Model: http://www.martinfowler.com/eaaCatalog/domainModel.html
Data Mapper: http://www.martinfowler.com/eaaCatalog/dataMapper.html
Unit of Work: http://www.martinfowler.com/eaaCatalog/unitOfWork.html
Separated Interface:
http://www.martinfowler.com/eaaCatal...Interface.html
I understand that the CSLA.NET framework from Rockford Lhotka is also a good
framework. http://www.lhotka.net/

Hope this helps
Jay

"Marc Castrechini" <mc@merchantwarehouseREMOVETHIS.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
First off this is a great reference for passing data between the Data Access and Business Layers:
http://msdn.microsoft.com/library/de...rchPatPrac.asp
I use my own classes in the Business layer. I want to keep the Data Access layer from requiring these classes so I tried passing a Datarow between the layers and it seems to work good for me. Constructing the datarow in the
Class for an update statement and simply passing it up from the Data Access layer for Loads.

Obviously, using this method I need to construct the DataRow in the class
and then parse it out in the Data Access layer to get it into the Parameters object to run my Update stored procedure. I am using a XmlSchema file so I know what the DataRow should look like in the Business layer.

I feel like I am mixing and matching technologies and missing an optimal
solution. My goal is to make the translation from a DataRow into the
Parameters object more dynamic. I don't want to have to change the DAL if I do something like add a field.

Can anyone point me in the right direction to achieve this? I have very
limited XML experience but if that is the answer then I will happily adopt
it. If you need clarification on anything please email directly or simly
reply to the group.

TIA (Sorry for the length of the post, if you are still reading)

- Marc Castrechini
mc@merchantwarehouseREMOVETHIS.com

Nov 20 '05 #3

P: n/a
That works well for setting up and parsing the datarow. Thank you.

I was hoping to create the parameters collection dynamically from the
dataset but I ran into the problem of not being able to know which kind of
SQLDbType each field is and the size of the field for SQLDbType.varchar from
the XMLSchema. The schema appears to store the field types as a
System.Type.

I'll stick with the DataRow iteration and manually adding parameters.

Thanks,
- Marc

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:aC*************@cpmsftngxa06.phx.gbl...
Hi Marc,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you have some confusion on how to
separate the business layer from data access layer.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

From me knowledge your design seems ok. Now you will share the xml file
which will descibe the datarow between the DAL and BL. When you add one
field into the the datarow, you will change the xmlfile, so that the DAL
and the BL will know the change. Also when you add one filed into the
datarow, will you also make some change to the DataBase, e.g. add a column
to one the table? If so I'd suggest you do not make two layer, since if you change the database, your DAL usually need to be changed too.

I also suggest you do not use the concret field name to access the
according field in the dataset in the DAL, so that when you pass the
datarow from BL to DAL, you do not need to make change, you can use the
statement such as "For Each...... Next" or Column(i).

If you still have more detailed question on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.