Now that I have completed the Business Objects it’s time to tackle the DAL(Data Access Layer).
Generally speaking, when you create your DAL start simple.

Using snippy I created a personnel snippy that looks like this:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Model;
using Microsoft.Practices.EnterpriseLibrary; // Download from here
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace DAL
{
public interface I()
{
List<> getAll();
void insert( args);
void update( args);
void delete();
}
public class (): NombersConnection, I()
{
Database db = createDataBase();
String sqlCommand;
DbCommand comd;
IDataReader reader;
List<> items;
item;
public List<> getAll()
{
reader = runQuery(db.GetSqlStringCommand(“”));
try
{
while(reader.Read())
{
items.Add( this.getRecord(reader));
}
}
finally
{
reader.Close();
}
return items;
}
public void insert( args)
{
throw new Exception(“The method or operation is not implemented.”);
}
public void update( args)
{
throw new Exception(“The method or operation is not implemented.”);
}
public void delete()
{
throw new Exception(“The method or operation is not implemented.”);
}
private () getRecord(IDataReader reader)
{
throw new Exception(“The method or operation is not implemented.”);
}
}
}

Notice there are four (4) methods in the interface.
1) getAll – used to retrieve all records from a single table.
2) insert – used to insert a single record into a single table.
3) update- used to update a single record into a single table.
4) delete- used to delete a single record into a single table.

There is a little work that you’ll need to do to complete the cs, this is used as a shell.
Now I could have do a SaveAs of an old DAL class, but the problem with that is if you forget to change one of your Business Objects, it will still compile and you won’t know there is an error.
Once the phase is complete I’ll start looking at the code and hopefully start converting this part.

Leave a Reply

Your email address will not be published. Required fields are marked *