Please visit DEMANDDRAFT.STORE for quality of products...

Ad

Search This Blog

Tuesday, July 7, 2015

How to get the Data using Stored Procedure with Parameter in MVC4 using Data base first approach



 private DBContext dbContext = new DBContext();

public List<UserAccess> GetOfficerNamesByOfficeTypeId(int officeTypeId)
        {
            var officeId = new SqlParameter { ParameterName = "OfficerTypeId", Value = officeTypeId };
            using (var dbContext = new DBContext())
            {
                var userAccess = dbContext.Database.SqlQuery<UserAccess>("exec USP_GetAllOfficerDetails_OfficerType  @OfficerTypeId ", officeId).ToList<UserAccess>();
                return userAccess.ToList();
            }
        }

No comments:

Post a Comment