Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best approach to make DAL?

I want to make a perfect custom DAL (data abstraction layer) class to use with all my projects.

I've searched the internet and found some samples for this but I never know which is the best approach.

Is it to make [Attributes]? Or use <Generics> or something else?

So please just give me a head line and I'll go on from there.

Thanks again and forgive my language.

like image 250
Wahid Bitar Avatar asked Nov 28 '22 10:11

Wahid Bitar


2 Answers

Just make sure you:

  • Always use stored procedures
  • Never use stored procedures
  • Sometimes use stored procedures
  • Use nHibernate
  • Use SubSonic
  • Use Entity Framework
  • Write your own
  • Never write you own
  • Use POCO
  • Use ActiveRecord
  • Use IRepository
  • Always do what Fowler says
  • Never do what Fowler says
  • Don't use Linq to SQL, it's dead
  • Use Linq to SQL, it's no longer dead

Do all that and you will be fine.

like image 144
Craig Avatar answered Dec 05 '22 01:12

Craig


Best approach is:

Don't do it yourself unless its for an academic research project or you intend to build a business shipping ORMs.

Try out the dozens of existing ORM solutions first. (Entity framework, subsonic, nhibernate etc etc...). They all have their quirks and limitations mixed in with tons of awesomeness.

ORMs are incredibly hard to get right and a huge undertaking.

Slightly related and on the money: http://wekeroad.com/2009/06/11/youre-not-your-data-access/

like image 26
Sam Saffron Avatar answered Dec 05 '22 02:12

Sam Saffron