canuckconsulting
asked on
Entity Framework 4.0 Repository example / primer
I could use an example solution or good primer on how to implement a repository in EF 4. I have a c# project where I have followed Julie Lerman's example presented at tech-ed 2010 (http://blogs.msdn.com/b/adonet/archive/2010/06/23/teched-north-america-sessions-online-now.aspx). It is working great with some simple scenarios but I am starting to get lost as I build it up.
One of my questions is should I have a static repository class available to the entire project? So when I create a repository passing in the connection details to my real or test context does everything in the project reference that same repository?
The next thing that confuses me is if do even entities reference this same repository class. for example if my program initialises the repository and then calls Order.Load("Open"). What if the Orders entity then needs to load another list say Customer.GetAll(). Would the Orders entity have to pass the context over to Customer or would Customer reference the repository to get the context.
As you can see I'm getting quite confused!
One of my questions is should I have a static repository class available to the entire project? So when I create a repository passing in the connection details to my real or test context does everything in the project reference that same repository?
The next thing that confuses me is if do even entities reference this same repository class. for example if my program initialises the repository and then calls Order.Load("Open"). What if the Orders entity then needs to load another list say Customer.GetAll(). Would the Orders entity have to pass the context over to Customer or would Customer reference the repository to get the context.
As you can see I'm getting quite confused!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.