|
Once more time Visual Studio has
promoted bad behavior in promoting RAD. To obtain the
functionality explained above, the datasets want to be in the
same project as the User Interface. But in the actual world,
it is superior to separate your business layer from your UI so
if you make a decision to implement a Web interface as a
substitute of Windows, much of the application will not want
to change.
We can accurate this easily
enough. Create a new Class Library project in your explanation
for your business objects. It is finest to start out with this
project and generate the original Data Set there as a
substitute of in the UI project.
If you have all set created
the application as in the above tutorial, you can shift the
layer we now created to the new project, but you want to also
shift the application file to remain the connection strings.
Create a new Class Library
project in your solution named Biz and shift the dataset here.
VS will really create a new copy of the dataset, leaving the
original alone. After copying the dataset, you will want to
remove the dataset in the Windows project. Your will also want
to search and replace the hard coded Namespace references,
changing "NorthlayerWin" to "NorthlayerBiz".
After the data set has been
produced, go back to the form and open the Data Sources panel.
This time when you add a new data source, as a substitute of
using the Database tool, choose the Object tool. On the next
screen, you will observe a list of referenced projects you
could utilize. If the reference is not exposed, you will
require clicking “Add Reference” button and choosing the
NorthlayerBiz project. Expand the project and select the
object. Select and Click ‘Next’ and ‘Finish’ and you will
observe the scheduled in the Data Sources Pane.
If you really create the
business project before creating the windows project, you will
observe a couple of differences. The Wizard no longer
routinely instantiates the table adapter in the form load
event. Because we are using an Object Data Source which might
not yet be a dataset, VS leaves the Data Access logic up to
us. We ought to write that code ourselves now, but quite than
write it in the Presentation layer; we require writing it in
the Business layer.
|