Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@liammclennan</p> <blockquote> <p>Which will return IEnumerable. ... Linq-to-sql is an ORM. It does not affect the way that you design an N-tiered application. You use it the same way you would use any other ORM.</p> </blockquote> <p>Then I guess I am still confused. Yes, Linq-to-Sql is an ORM; but as far as I can tell I am still littering my front end code with inline sql type statements (linq, not sql.... but still I feel that this should be abstracted away from the front end).</p> <p>Suppose I wrap the LINQ statement we've been using as an example in a method. As far as I can tell, the only way I can return it is this way:</p> <pre><code>public class EmployeesDAL { public IEnumerable LoadEmployeesAndManagers() { MyCompanyContext context = new MyCompanyContext(); var emps = from e in context.Employees join m in context.Employees on e.ManagerEmpID equals m.EmpID select new { e, m.FullName }; return emps; } } </code></pre> <p>From my front end code I would do something like this:</p> <pre><code>EmployeesDAL dal = new EmployeesDAL; var emps = dal.LoadEmployeesAndManagers(); </code></pre> <p>This of course returns an IEnumerable; but I cannot use this like any other ORM like you say (unless of course I misunderstand), because I cannot do this (again, this is a contrived example):</p> <pre><code>txtEmployeeName.Text = emps[0].FullName </code></pre> <p>This is what I meant by "I lose strong typed goodness." I think that I am starting to agree with Crucible; that LINQ-to-SQL was not designed to be used in this way. Again, if I am not seeing things correctly, someone show me the way :)</p>
 

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