Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am using the generic repository approach to entity framework code first. If I need to write a complex LINQ query, what is the best way to do it? I think the whole point to repository pattern is to access the DBContext from the repository and not directly in my code. Where should I create this complex query? I dont think I should be using the context outside my repository, but I want to see what others have to say about this kind of situation.

Thank you
Posted
Updated 19-Sep-13 5:35am
v2
Comments
Ryanm1324 18-Sep-13 11:43am    
Is it not good practise to use the context directly for this situation and not the repository

1 solution

It is not a good practice to write outside the generic repository pattern and you will be defeating the whole purpose of having the repository pattern

You could customize the repository pattern for your special requirement and still have it under repository pattern and it is not recomanded to access the DBcontext directly
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900