Reading values from DBML(having stored procedure)

ruphert756

New Member
I have a dbml that has stored procedures dragged off.I have EmployeeModel class that has get and set propertise .I have an interface IEmployee and a Repository Employee Repository that has the implementation of the methods.Please refer the code.In Stored procedure GetRoles i just have SELECT * FROM ROLE .In repository how to loop through the resultset.Can i change ISingleResult to IMultipleResult in dbml designer file?EmployeeModel.cs:\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace MvcWebsite.Models{ public class EmployeeModel { public int RoleId { get; set; } public string RoleName { get; set; } public string Description { get; set; } public string TaskMark { get; set; } public int RoleFlag { get; set; } }}\[/code\]IEmployee:\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Text;using MvcWebsite.Models;namespace MvcWebsite.DAL{ public interface IEmployees { IList<EmployeeModel> ListAll(); // void Save(EmployeeModel employ); }}\[/code\]EmployeeRepository.cs:\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Web;using MvcWebsite.Models;using System.Data.Linq;namespace MvcWebsite.DAL{ public class EmployeeRepository:IEmployees { private DataDataContext _dataContext; public EmployeeRepository() { _dataContext = new DataDataContext(); } public IList<EmployeeModel> ListAll() { //IMultipleResults result =_dataContext.GetRoleDetails(); //var Emps = result.GetResult(EmployeeModel); List<EmployeeModel> emp = _dataContext.GetRoleDetails(); // foreach (GetRoleDetailsResult role in Emps) // { // role.Description=Emps. // } return Emps.ToList(); } }}\[/code\]
 
Back
Top