views:

137

answers:

1

Hi everybody,

I'm going to write my own DAL in C#. I decided to use 'Unit of Work' pattern (next mentioned as uow) with request as a scope and Identity map stored in HttpContext.Items.

I have right now question about implementing of CRUD methods. How/where are they implemented? Are they implemented in every single business class (as in active records pattern) or are implemented somehow in uow class (if so, how)?

I also suppose that I need to use as the scope not just the request, but also the db connection. But how? Should I open the connection a the start of the request and close it on uow disposing?

Every advice is strongly appreciated, especially Your "real world" experiences.

Thank you all :)

+1  A: 

By the sounds of it, you're trying to develop your own Object-relational mapping. I would say, don't try to go even near writing your own.

On-topic, one of the active contributers to the nHibernate ORM package, Davy Brion, has written a tutorial which includes how to write a simple ORM step-by-step.

He says that he's spend 24 hours writing the tutorial, so don't expect it to have anything near a production-ready ORM package.

Also, the tutorial is meant to explain how an ORM works, rather than actually motivating you to write a rival to the product nHibernate, the product he's contributing to.

Build Your Own Data Access Layer Series

taoufik