Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>1.Does it matter that there is no clear distinction between BLL and the DAL?.</p> </blockquote> <p>It sure does matter! Any programmer that uses your Table property needs to understand the ramifications (database roundtrip, query translation, object tracking). That goes for programmers reading the business logic classes as well.</p> <blockquote> <p>2.Is queryability considered data access or business logic when behind a Repository layer that acts like an InMemory abstraction?</p> </blockquote> <p>Abstraction is a blanket that we hide our problems under.</p> <p>If your abstraction is perfect, then the queries could be abstractly considered as operating against in-memory collections and therefore they are not data access.</p> <p>However, abstractions leak. If you want queries that make sense in the data world, there must be effort to work above and beyond the abstraction. That extra effort (which defeats abstraction) produces data access code.</p> <hr> <p>Some examples:</p> <pre><code>output = work.GetRepository&lt;Bar&gt;().Table.ToArray(); </code></pre> <p>This is code is (abstractly) fine. But in the data world it results in scanning an entire table and is (at least generally) dumb!</p> <hr> <pre><code>badquery = work.GetRepository&lt;Customer&gt;().Table.Where(c =&gt; c.Name.Contains("Bob")).ToArray(); goodquery = work.GetRepository&lt;Customer&gt;().Table.Where(c =&gt; c.Name.StartsWith("Bob")).ToArray(); </code></pre> <p>Goodquery is better than bad query when there's an index on <code>Customer.Name</code>. But that fact is not available to us unless we lift the abstraction.</p> <hr> <pre><code>badquery = work.GetRepository&lt;Customer&gt;().Table .GroupBy(c =&gt; c.Orders.Count()) .Select(g =&gt; new { TheCount = g.Key, TheCustomers = g.ToList() }).ToArray(); goodquery = work.GetRepository&lt;Customer&gt;().Table .Select(c =&gt; new {Customer = c, theCount = c.Orders.Count()) .ToArray() .GroupBy(x =&gt; x.theCount) .Select(g =&gt; new { TheCount = g.Key, TheCustomers = g.Select(x =&gt; x.Customer).ToList() }) .ToArray(); </code></pre> <p>goodquery is better than bad query since badquery will requery the database by group key, for each group (and worse, it is highly unlikely there is an index to help with filtering customers by <code>c.Orders.Count()</code> ).</p> <hr> <blockquote> <p>Testability is built into the Repository design. We can leverage the InMemory implementation to assert results with expectations.</p> </blockquote> <p>Be under no illusions that your queries are being tested if you actually run them against in-memory collections. Those queries are untestable unless a database is involved.</p>
    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. VO
      singulars
      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