Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Greetings to all

I am using unit of work, repository pattern with entity framework 6 (code first approach) along with dependency injection,

I have extended my repository to execute stored procedures as below

public List<tentity> ExecuteStoreProcedure(IUnitOfWork unitofWork, string spName, params object[] parameters)
{
return ((DataContext)unitofWork.getDBContext()).Database.SqlQuery<tentity>(spName, parameters).ToList();
}


my questions are.
1.How can I call my call my stored procedures using this design pattern(is what I am doing is correct).
2.How can I make entity framework generate classes to hold the data from my stored procedures on the fly(<tentity>).
a) I have lots of stored procedures and I do not want to create POCO classes for all of them.
Posted
Updated 21-Oct-14 0:14am
v3

1 solution

Hi Vailbhav Nigam.

If u r Free then u can checkout the below link

http://www.remondo.net/repository-pattern-example-csharp/[^]
 
Share this answer
 
Comments
vaibhavnigam383 21-Oct-14 5:50am    
The solution provided is a generic implementation of Repository
My concern is as to how can I call my Sps using repository and return a class(entity) on the fly as Entity Framework only entertains Entity types.
payne173 21-Oct-14 5:52am    
I don't have in depth knowledge on this subject Vaibhav.
We have exact same requirement.
Next Week I am going to start working on this.
May be i can help then..

Thanks..
vaibhavnigam383 19-Nov-14 8:47am    
I still am looking for a feasible solution ti this..any help will be appreciated.
shahzadbeg 31-Mar-15 19:17pm    
Yes ,Vaibhav mee too stuck with it from last 4 hours , but still am investigating ..but not found any solution for the same

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