Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Seriously speaking, LINQ to SQL had it's support for n-tier architecture see DataContext.Update method</p> </blockquote> <p>Some of what I've read suggests that the business logic wraps the DataContext - in other words you wrap the update in the way that you suggest. </p> <p>The way i traditionally write business objects i usually encapsulate the "Load methods" in the BO as well; so I might have a method named LoadEmployeesAndManagers that returns a list of employees and their immediate managers (this is a contrived example) . Maybe its just me, but in my front end I'd rather see e.LoadEmployeesAndManagers() than some long LINQ statement. </p> <p>Anyway, using LINQ it would probably look something like this (not checked for syntax correctness):</p> <pre><code>var emps = from e in Employees join m in Employees on e.ManagerEmpID equals m.EmpID select new { e, m.FullName }; </code></pre> <p>Now if I understand things correctly, if I put this in say a class library and call it from my front end, the only way I can return this is as an IEnumerable, so I lose my strong typed goodness. The only way I'd be able to return a strongly typed object would be to create my own Employees class (plus a string field for manager name) and fill it from the results of my LINQ to SQL statement and then return that. But this seems counter intuitive... what exactly did LINQ to SQL buy me if I have to do all that?</p> <p>I think that I might be looking at things the wrong way; any enlightenment would be appreciated.</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