In MVC application generally we are using entity frame work (dbcontext) to manage and retrieve database related operation, but in some case suppose we have few complex logic for that need to write store procedure so below are the code for retrieve data from store procedure in MVC Mode by entity frame work.
In this class I have inherited by “DBContext” class so “Database” is part of data context.
1 | public List<Menu> GetMyData( long intUserID) |
3 | List<Role> oMenuList = new List< Role >(); |
4 | Business.Model. Role oRole = new Role (); |
6 | List<Role> oMenuDataList = this .Database.SqlQuery<Menu>( "exec GetRoleData {0}" , intUserID).ToList<Role>(); |
In Above code List<Role> Role is model so that is fill by storeprocedure “GetRoleData”.
0 comments:
Post a Comment