473,394 Members | 1,750 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,394 software developers and data experts.

Domain Model Structure

I am starting a new project and I always and looking for a better way
to skin a cat. Anyway, I am interested in seeing how different people
have implemented an N-Tier type architecture (using business objects)
for their applications...

The mains things I am interested in seeing is how you have setup each
tier to talk to each other, how the OR mapping stuff happens,
realtionships between objects (LazyLoad?), etc.

For simplicity please just show how using your design you would Insert,
Update, Delete, Get a CustomerObject and also how you would...
Example #1:
Customer Object:
public class Customer
{
public Customer() {}

private int m_id;
private string m_firstName;
private string m_lastName;
private string m_address;

[DataField("iCustomerID")]
public int ID
{
get{ return m_id; }
set{ m_id = value; }
}

[DataField("vchFirstName")]
public string FirstName
{
get { return m_firstName; }
set { m_firstName = value; }
}

[DataField("vchLastName")]
public string LastName
{
get { return m_lastName; }
set { m_lastName = value; }
}

[DataField("vchAddress")]
public string Address
{
get { return m_address; }
set { m_address = value; }
}
}

Manager Class:

usage:
CustomerManager manager = new CustomerManager();

//Get from DB
Customer customer = manager.GetByID(666);

//Update
customer.FirstName = "New Name";
manager.Update(customer);

//Insert
Customer newCustomer = new Customer();
newCustomer.FirstName = "Hello";
newCustomer.LastName = "Dolly";
newCustomer.Address = "1234 Somewhere Place";

implementation:
public class CustomerManager
{
public Customer GetByID(int customerID)
{
DALCustomer customer = new DALCustomer();
DataTable dtCustomer = customer.GetByID(customerID);
Customer customer = new Customer();

//The mapper class uses refelection to map the datatable columns to
//business object properties use the DataField attribute
DataMapper.Map(customer, dtCustomer);
return customer;
}

public void Update(Customer customer)
{
DALCustomer dalCustomer = new DALCustomer();
dalCustomer.Update(customer.ID, customer.FirstName,
customer.LastName, Customer.Address);
}

public void Insert(Customer customer)
{
DALCustomer dalCustomer = new DALCustomer();
int customerID = dalCustomer.Insert(customer.FirstName,
customer.LastName, Customer.Address)
customer.ID = customerID;
}
}

DataMapper:
public class DataMapper
{
public void Map(object entity, DataTable data)
{
//each property in the business object has an "Attribute" that
defines the OR Mapping
}
}

DataLayer:
- For each table there is a DataLayer object.
- Each object has the basic CRUD methods calling StoredProcs

implementation:
public class DALCustomer
{
public static DataTable GetByID(int customerID)
{
// Create Connection
// Create Command using Stored Procedure
// Return Dataset
}

public static int Insert(string firstName, sting lastName, string
address)
{
// Create Connection
// Create Command using Stored Procedure
// Add output paramter for new customerID

return customerID;
}

public static void Update(int customerID, string firstName, sting
lastName, string address)
{
// Create Connection
// Create Command using Stored Procedure
}
}

Nov 17 '05 #1
0 1082

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Iain Bishop | last post by:
I'm trying to model objects for the following problem: A building site contains assemblies, each of which can contain other assemblies and/or materials. I have modelled this using a Site...
7
by: pysim | last post by:
Hi, I have a couple of general requests for pointers to python examples and design advice. I'm looking for examples of MVC-based GUI controls done in python (model-view-controller). Also,...
7
by: jason | last post by:
I am getting twisted by the possibility that my virtual includes which currently work great on non-domain remote IP will crash if I purchase a domain and point it to one of my designated...
1
by: Rahul Chatterjee | last post by:
Hello all I have a web page which has 3 frames. The top and the left navigation frames are on a separate domain. The right display frame initially starts on the same domain as the other two...
6
by: Charles Crume | last post by:
Hello; My index.htm page (www.charlescrumesoftware.com for those interested in looking) contains 3 frames (left = content, top right = logo, bottom right = navigation). This domain name is...
2
by: Infant Newbie | last post by:
I have a windows 2003 domain with 2 servers - one for sql server 2000 and another as iis. When my asp.net app connects to the sql server I get the above error. I modified the <processmodel>...
1
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
3
by: cmay | last post by:
I am trying to build more applications using a more OO approach, with more seperation of business and presentation logic. One problem I am running into involves the design philosophy behind...
3
by: Joe User | last post by:
Hi - I found the class below on another website (www.devx.com) and can't seem to figure out how to make a call to this class to retrieve the machines and put them in a listbox. I am definitely a...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.