C# Design How to Elegantly wrap a DAL class
Posted
by guazz
on Stack Overflow
See other posts from Stack Overflow
or by guazz
Published on 2010-04-29T21:07:50Z
Indexed on
2010/04/29
21:17 UTC
Read the original article
Hit count: 738
I have an application which uses MyGeneration's dOODads ORM to generate it's Data Access Layer. dOODad works by generating a persistance class for each table in the database. It works like so:
// Load and Save
Employees emps = new Employees();
if(emps.LoadByPrimaryKey(42))
{
emps.LastName = "Just Got Married";
emps.Save();
}
// Add a new record
Employees emps = new Employees();
emps.AddNew();
emps.FirstName = "Mr.";
emps.LastName = "dOOdad";
emps.Save();
// After save the identity column is already here for me.
int i = emps.EmployeeID;
// Dynamic Query - All Employees with 'A' in thier last name
Employees emps = new Employees();
emps.Where.LastName.Value = "%A%";
emps.Where.LastName.Operator = WhereParameter.Operand.Like;
emps.Query.Load();
For the above example(i.e. Employees DAL object) I would like to know what is the best method/technique to abstract some of the implementation details on my classes. I don't believe that an Employee class should have Employees(the DAL) specifics in its methods - or perhaps this is acceptable? Is it possible to implement some form of repository pattern? Bear in mind that this is a high volume, perfomacne critical application.
Thanks, j
© Stack Overflow or respective owner