473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing Business object to Dabase Layer causes Problems, Help Needed..

Hi,

I have a been developing an accounting system for a non-profit organization. I had decided to to divide the solution, in three layers, presentation, business layer and database layer.

My business layer is composed of objects like Account, Transaction, Voucher etc. And my database layer is composed of objects like AccountDB, TransactionDB, VoucherDB.

Now each of my layer is residing in a seperate project under the same solution. And i wanted, my database objects with functions like insert(Transaction tranasaction). So I'm passing my business objects to my database objects functions, for that purpose i have the references to my database objects in my business objects.

So I'm in a position that i need a reference to my database project in my business project, and also my business project reference in my database project. Is there any way i can do this without having circular references?

Thanks in advance..

waheed.
Mar 29 '07 #1
3 1350
Frinavale
9,735 Expert Mod 8TB
Hi,

I have a been developing an accounting system for a non-profit organization. I had decided to to divide the solution, in three layers, presentation, business layer and database layer.

My business layer is composed of objects like Account, Transaction, Voucher etc. And my database layer is composed of objects like AccountDB, TransactionDB, VoucherDB.

Now each of my layer is residing in a seperate project under the same solution. And i wanted, my database objects with functions like insert(Transaction tranasaction). So I'm passing my business objects to my database objects functions, for that purpose i have the references to my database objects in my business objects.

So I'm in a position that i need a reference to my database project in my business project, and also my business project reference in my database project. Is there any way i can do this without having circular references?

Thanks in advance..

waheed.
I've done something similar in one of my projects.

I've created a small class library that handles all of my database transactions. In my main application I referenced this class library and created a class (called DatabaseHandler) that would server as an interface between the database class library and my application's custom objects.

DatabaseHandler accepted my applications custom objects as parameters and then called my database class library's functions...providing them with the information needed to properly fill the tables that are retrieved from my custom objects.


Eg. (in Pseudocode)

Expand|Select|Wrap|Line Numbers
  1. [Database Project]
  2.  
  3. Class DatabaseManipulator
  4.      Function UpdateTableA( int id, string name...)
  5.      Function UpdateTableB(int id, string code....)
  6. End Class
  7.  
  8. [/Database Project]
  9.  
  10. [Main Application (references Database Project)]
  11. Class A
  12.      Property ID 
  13.      Property Name
  14. End Class
  15.  
  16. Class B
  17.      Property ID
  18.      Property Code
  19. End Class
  20.  
  21. Class DatabaseHandler
  22.      Function FillTableA( Class A ...)
  23.      {
  24.          DatabaseManipulator.UpdateTableA(A.id, A.name...)
  25.      }
  26.  
  27.      Function FillTableA( Class B...)
  28.      {
  29.          DatabaseManipulator.UpdateTableB(B.id, B.code...)
  30.      }
  31. End Class
  32. [/Main Application]
  33.  
  34.  
So, whenever I needed to update the database with a validated custom object I'd just call my DatabaseHandler's function and passed my custom object to it ...which would send it to my database class library to do the work for me.

Hope this helps!

-Frinny
Mar 29 '07 #2
Thanks Frinny, that seems a nice solution to my problem...

waheed.
Mar 31 '07 #3
Frinavale
9,735 Expert Mod 8TB
Thanks Frinny, that seems a nice solution to my problem...

waheed.
Glad to have helped
:)
Mar 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Arsen Vladimirskiy | last post by:
Hello, If I have a few simple classes to represent Entities such as Customers and Orders. What is the proper way to pass information to the Data Access Layer? 1) Pass the actual ENTITY to...
25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
3
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers:...
2
by: et | last post by:
In my asp.net 1 program, I have a business layer, which lays out all my business rules, and of course communicates with the data layer, which accesses a sql database and returns data. No problems....
6
by: Guy Thornton | last post by:
I have an application in asp.net using vb. The asp.net portion of this application is mainly the user interface. The UI has references made to our business logic layer. And the business logic...
25
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as...
3
by: =?Utf-8?B?QmFycnkgR2lsYmVydA==?= | last post by:
I would like a particular business object to ask for validation when a property is set to a specific value. In this case, I have a TimeStart property and a TimeEnd property. When creating a new...
2
by: Chris Zopers | last post by:
Hello, I would like to know what's the best way to implement a business logic layer between my user interface and my database. I would say I'd make a dll-project for the business logic layer...
8
by: Charles Law | last post by:
This is a sort of pattern question, but relating to how components are coupled in a three-tier system. I have a presentation layer, business layer and data access layer, the first is the EXE,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.