Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can loop through the resultset as below:</p> <pre><code> List&lt;EmployeeModel&gt; employeeModels = new List&lt;EmployeeModel&gt;(); foreach (EmployeeModel employeeModel in _dataContext.GetRoleDetails()) { employeeModels.Add(employeeModel); } </code></pre> <p>Or you can use System.Linq.Enumerable class ToList&lt;> method as below:</p> <pre><code>List&lt;Product&gt; products = context.GetProducts().ToList&lt;Product&gt;(); </code></pre> <p>IMultipleResults is used when stored procedure is returning more than one result sets. However when you drop such procedures on to the designer, it doesn't generate IMultipleResults. For this you can change the designer generated code to use IMultipleResults as below:</p> <pre><code>[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetCustomerAndProducts")] [ResultType(typeof(Customer))] [ResultType(typeof(Product))] public IMultipleResults GetCustomerAndProducts() { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod()))); return ((IMultipleResults)(result.ReturnValue)); } </code></pre> <p>However, it would overwrite your modifications when you do any changes in the designer because it would regenerate the code. To avoid this you can use partial classes.</p> <p>Or you can also use SqlMetal tool. It is a command-line tool that generates code and mapping for the LINQ to SQL component of the .NET Framework. This tool generates IMultipleResults. You can get the details for this tool here:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb386987.aspx</a></p> <p>Edited:</p> <p>Repository functionality will be same regardless of you work in ASP.Net Mvc or WinForms or any other presentation layer.</p> <p>You can change your repository function to below:</p> <pre><code>public List&lt;EmployeeModel&gt; ListAll() { return _dataContext.GetRoleDetails().ToList&lt;EmployeeModel&gt;(); } </code></pre> <p>Or:</p> <pre><code>public List&lt;EmployeeModel&gt; ListAll() { List&lt;EmployeeModel&gt; employeeModels = new List&lt;EmployeeModel&gt;(); foreach (EmployeeModel employeeModel in _dataContext.GetRoleDetails()) { employeeModels.Add(employeeModel); } return employeeModels; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload