Question

Just started a 'real world' project using .NET MVC, Ninject, PetaPoco and plan to use the repository pattern.

I used the PetaPoco T4 template w/ 'GenerateOperations', 'GeneratePocos', and 'GenerateCommon' all = true. Looking at the generated code, it seems to make sense to extract the 'Record' class into a generic repository interface and/or class, but I haven't been able to wrap my head around how to go about it.

With my limited DI knowledge, it also seems to make sense to tie the 'GetInstance' piece into Ninject somehow on a 'per-request' basis - but how should I go about it?

In case it isn't apparent already, I'm a newbie to DI, the repository pattern and PetaPoco. :)

Was it helpful?

Solution

I spent a long time over thinking the repo pattern, in the end I decided simple is best..

The Repo I posted on my blog is not yet complete, but it will give you a good start ( I have made changes since that post.. if you want them I can zip something up).

I was a little restricted in my implimentation as I was moving from another DA so had to make my PetaPoco repo work in the same way as my previously defined patern.. but it works and thats what the repository patterns all about.

I'm afraid I'm just learning DI myself so Im not able to help you with that at the moment.

OTHER TIPS

Check out this guys blog post - he's doing exactly what you want as far as setting up a repository pattern with petapoco.

With regards to setting up MVC3 + Ninject + Repositories, its answered in this question.

On a recent project I've been using asp.net mvc3, autofac and petapoco - using the repository pattern with out a worry.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top