Saturday, 25 July 2009

Repository Factory

Looking for a tool which generates the data access layer for you? Download Repository Factory Guidance Package from here. Previously it was part of Web Service Software Factory but now it’s separated to be independent.

I used this tool for about 1.5 years for one of my applications which was developed by WSSF.

What can I generate with it?

Using this tool you can generate:

  • CRUD stored procedure for your Database Tables
  • Business Entity classes for your Tables
  • Data access layer (Repository classes) for your Business Entities: Repository Interfaces, Repository Classes and RepositoryFactory

If you need to create any new custom methods for your repositories, you can easily do so using partial classes in which way you can always benefit from generated codes by Repository Factory.

Repository Factory Pattern - Code Example:

// Repository Interface
public interface ICustomerRepository
Customer GetCustomersByCustomerId(System.Int32 customerId);
List<Customer> GetAllFromCustomers();
void Add(Customer customer);
void Remove(System.Int32 customerId);
void Save(Customer customer);

// Repository
public partial class CustomerRepository : Repository<Customer>, ICustomerRepository

public CustomerRepository(string databaseName) : base(databaseName) { }

public CustomerRepository() : base() { }

public List<City> GetAllFromCustomer() { }

public void Add(Customer customer) { }

public void Remove(System.Int32 customerId) { }

public void Save(Customer customer) { }


// Repository Factory
public class RepositoryFactory<T>
public T Create() { }

// How to use it
class Program
static void Main(string[] args)
ICustomerRepository repository =

  Customer customer = repository.GetCustomersByCustomerId(1);


No comments: