0

I have read two questions from stackoverflow.com

  1. Is Classic ADO.NET still used?
  2. Using ASP.Net MVC with Classic ADO.Net

I really appreciate both of them.
I like Repository Design Pattern so much that I would like to use it at my project which use ASP.net MVC and Classic Ado.net.

Above question No. 2 have explained about how could I use repository pattern and classic ado.net technologies.

One thing I would like to know is that Is this possible to use Repository pattern which combined with Unit of work , when it comes to classic ado.net technologies.

Could anyone please give me any reference links about that?

If there is references only for Repository + Classic Ado.net, then let me know that reference as well.

Community
  • 1
  • 1
Frank Myat Thu
  • 4,448
  • 9
  • 67
  • 113
  • What is the point of using pure ado.net if you want to put UOW over it? The idea of using pure ado.net is to control exactly what happens (mostly from a performance perspective). If you are planning to use UOW, why not using an ORM like EntityFramework? – Ivo Feb 08 '12 at 05:05
  • @ivowiblo First of all, let me say to you that I thank you for your comment. Yes I have used EF Code First Desgin pattern for another project. But One issue is happen when it comes to incremental database building. Because EF Code First design pattern support drop crate database way. – Frank Myat Thu Feb 08 '12 at 05:09
  • But it does support incremental DB building. You could use DataBase first if you want: http://msdn.microsoft.com/en-us/data/gg685489 – Ivo Feb 08 '12 at 05:10
  • You know, you can update your DataContext anytime you want... – Ivo Feb 08 '12 at 05:11

2 Answers2

3

It is indeed possible to combine UoW, Repository and 'classic' ADO.NET.

Your UoW will need to get to the relevant repository based on the entity type, though. You could have your repositories implement a generic interface. For instance:

public interface IRepository<T>
{
    void Add(T instance);
    T Get(Guid id);
    void Remove(Guid id);
    void Remove(T instance);
}

Since each UoW is a separate instance you will want to use a factory. This factory will then either inject the repositories into the UoW or give it some IRepositoryProvider instance that can return the relevant repository based on type. So conceptually:

public interface IRepositoryProvider
{
    IRepository<T> Get<T>();
}

These are very broad strokes so I hope that makes sense.

Eben Roux
  • 12,983
  • 2
  • 27
  • 48
2

IMO if you want to use Repository and UoW there is no reason to use "classic" ADO.Net. The various ORM frameworks implement the Repository+UoW patterns for you, you just plug them into your applications (assuming your app is designed around these patterns).

I'd only use classic ADO.Net when I didn't want to use Repository/UoW patterns (e.g. Transaction Script pattern).

Dylan Smith
  • 22,069
  • 2
  • 47
  • 62
  • Thank you @Dylan Smit, I accept what you said. So Could you please tell me any references for using Repository + classic Ado.net without considering to combine UOW. – Frank Myat Thu Feb 08 '12 at 06:24
  • @dylan u said "The various ORM frameworks implement the Repository+UoW patterns for you" can u tell me few ORM framework which has in-built Repository and UoW. because i saw people write code to develop Repository pattern when they work with EF. – Mou Sep 07 '15 at 09:11