Passing data - BUS to DAL to Param object?

  • Thread starter Marc Castrechini
  • Start date
M

Marc Castrechini

First off this is a great reference for passing data between the Data Access
and Business Layers:
http://msdn.microsoft.com/library/d...s/dnanchor/html/Anch_EntDevAppArchPatPrac.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
(e-mail address removed)
 
P

Peter Huang

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.
 
J

Jay B. Harlow [MVP - Outlook]

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/eaaCatalog/separatedInterface.html


I understand that the CSLA.NET framework from Rockford Lhotka is also a good
framework. http://www.lhotka.net/

Hope this helps
Jay
 
M

Marc Castrechini

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
 
M

[MSFT]

Hi Marc,

In a DataSet Schema, a varchar will be present as:

<xs:element name="xxx" type="xs:string" minOccurs="0" />

We only can know it is a string type and can't figure out its size.

Luke
Microsoft Online Support

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

Peter Huang

Hi Marc,

Did Luke's suggestion answer your question, if you still have any question,
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.
 

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

Top