I have a stored procedure that returns a result set (4 columns xn rows). The data is based on several tables in my database and contains a summary for each department in the corporate environment. Here is an example:
usp_GetDepartmentSummary DeptName EmployeeCount Male Female HR 12 5 7 etc...
I am using linq-to-sql to retrieve data from my database (nb - use sproc since this is what I inherited). I would call the above sproc and map into the department class:
public class Department { public string DeptName {get; set;} public int EmployeeCount {get; set;} public int MaleCount {get; set;} public int FemaleCount {get; set;} }
In VS2008, I can drag my sproc onto the linq-to-sql constructor method panel. When I examine designer.cs , the return type for this sproc is defined as:
ISingleResult<usp_GetDepartmentSummaryResult>
What I would like to do is change this so that it returns a Department type so that I can pass the results of sproc as a strongly typed view:
<% foreach (var dept in Model) { %> <ul> <li class="deptname"><%= dept.DeptName %></li> <li class="deptname"><%= dept.EmployeeCount %></li> etc...
Any ideas how to achieve this?
NB. I tried directly modifying designer.cs and dbml xml file , but with limited success. I admit that I am a little behind my depth when it comes to updating these files directly, and I'm not sure if this is the best practice? It would be nice to get some recommendations.
thanks a lot
source share