I am creating a sample, application to understand repository and factory method patterns together, because will use in a bigger project.
What i want to achieve is be able to make the website work with different ORM tools.
For example the website will have LINQ to SQL and Ado entity frame work classes implemented then using the factory method will use one of these ORMs "using config value" to load the data in the repository objects.
What i got till now is like the following
interface IRepository : IDisposable
{
IQueryable GetAll();
}
interface ICustomer : IRepository
{
}
public class CustomerLINQRepository : ICustomer
{
public IQueryable GetAll()
{
// get all implementation using linqToSql
}
public void Dispose()
{
throw;
}
public IRepository GetObject()
{
return this;
}
}
public class CustomerADORepository : ICustomer
{
public IQueryable GetAll()
{
// get all implementation using ADO
}
public void Dispose()
{
throw new NotImplementedException();
}
public IRepository GetObject()
{
return this;
}
}
// Filling a grid with data in a page
IRepository customers = GetCustomerObject();
this.GridView1.DataSource = customers.GetAll();
this.GridView1.DataBind();
////
public IRepository GetCustomerObject()
{
return new CustomerLINQRepository(); // this will return object based on a config value later
}
But i can feel that there are a lot of design mistakes hope you can help me figure it out to get better design.