Concepts of Multi Tier VB.NET Application
Posted on 2010-09-23
I'm trying to get my head around the processes needed for developing a multi-tier vb.net database application.
In my solution I have three projects - the user Interface (windows app), the business object (class) and the data access layer (class), with references in place (UI refs the BO, BO refs the DAL)
The approach I'm currently trying to take is this:
My data access class contains a dataset consisting of several strongly typed DataTables and TableAdapters, with the relevant methods for retrieving data - UPDATE, INSERT and DELETE statements and methods were automatically generated.
My business layer contains the classes for my business objects, with the relevant properties and methods etc. I want all my business logic / rules to go in here.
My UI then needs to bind to the various business objects.
What I'm struggling to get my head around is how to effectively link the three together.
Currently each of my business classes has a Create method which calls the relevant TableAdapter method to populate a DataTable. Two approaches I've tried from inside this method are:
1: read the column values from the returned datarow and assign the values to the class properties / fields and then return a UserDefined Type to the UI and bind to the Object properties (how to updates to the properties in the UI get back to the database through the DAL)
2: return the DataTable to my UI and somehow bind to that. I'm guessing that this approach wouldn't have the object properties to bind to, but maybe the data columns instead. (How do I apply the business logic to a datatable, it's columns and values?)
The question I have really is this. What is a good, sensible approach for doing this kind of thing? Bear in mind it's not a huge app (at the moment), and I'm all for an easy(ish) life when it comes to coding.
I have more specific questions but that can wait for another day - I'm just trying to get my head around the concepts. I've searched around for answers and there seems to be a lot of discussion about Datasets vs. Business Objects - am I wrong to think that I can / should have both :)
Sorry to ramble. Looking forward to some Expert guidance.