Re: project references when building N-tier apps

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



This was great help - thanks! I decided to go with method 3 which
probably requires one more post before i can leave this newsgroup free
of my newbieness!

On Mon, 8 May 2006 22:34:13 +0000 (UTC), Robert Wilczynski
<wilczynski.robert@xxxxxxxxx> wrote:

Hi Owen,

There are at least 3 things you could do:

1) Extract business objects (or data objects) such as User into a third assembly
which you then reference from both > Business.dll and DataAccess.dll. In
this scenario they will share the common type. If you want to have "active"
objects

eg.:

User user = new User("username", email@xxxxxxxxxxxxx");
user.Save();

then it's probably a bad solution but if the classes are only for carrying
data then that may be the way to go.

2) Make UserCRUD Get methods return IDataReader and construct the object
in the Business.dll (you can have the object construction logic in another
assembly). Insert methods would then have to take multiple parameters (each
property of your User object eg.: UserCRUD.Insert(string userName, string
email) instead of accepting the actual instance of the User class).

3) Make the User class (Business.dll) inherit from UserData class (DataAccess.dll
or better yet a separate assembly). Data access layer would then return an
instance of UserData (only a data carrying object) class which could be transformed
into a business object (User class). This would allow the business objects
to call the data access layer and provide the above mentioned user.Save()
functionality.

You can also look around for ORM tools, see what kind of code those give
you and use those ideas.

Does that help?

Best regards,
Robert Wilczynski.

Hi,

I am making a first attempt at building a n-tier app and have it
organised with the following projects:

GUI.exe
Business.dll
DataAccess.dll
GenericDA.dll
data access references genericDA, business references the dataaccess,
and GUI references business projects but my problem comes becuase of
the way i want to seperate my classes, which i can best explain using
an example: i have a table called user - which has a username and
email address. my DataAccess.dll has a class called UserCRUD which
reads and writes to the database,the get method of UserCRUD has a
return type of User -this return type i want to define in the Business
layer but i cant figure out how to connect the two layers - how do i
make the dataaccess layer aware of the business layer? i tried adding
a project reference to my business project but it says that is a
circular reference. Can someone tell me what i am doing wrong? is it
possible for me to reference a business layer defined object in my
dataaccess layer? if not is there a better way to approach this?

Many thanks
Owen

.



Relevant Pages

  • Re: Classes, collections and data
    ... Being that it is a small app, putting the data access and business logic ... Normally I create a Business Layer that handles logic, calculations, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: App Architecture: Typed Datasets, EntLib, Performance
    ... Deploying Business Entities ... and have typed datasets as the common ... Some say that they should not be filled by the data access ... layer, but rather should exist only in the business layer, which would ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: App Architecture: Typed Datasets, EntLib, Performance
    ... Deploying Business Entities ... and have typed datasets as the common library ... Some say that they should not be filled by the data access ... layer, but rather should exist only in the business layer, which would ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Circular dependency
    ... Then both the Data Access Layer and the Business Logic Layer ... I expected to seperate each layer into different projects and reference ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: project references when building N-tier apps
    ... Extract business objects such as User into a third assembly which you then reference from both> Business.dll and DataAccess.dll. ... Data access layer would then return an instance of UserData class which could be transformed into a business object. ... and GUI references business projects but my problem comes becuase of ...
    (microsoft.public.dotnet.distributed_apps)