Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On the first point, you are correct, from a "SOLID" perspective. Instead of handling the persistence itself, it would be more maintainable and less redundant to implement a CaseDataMapper that is used by the ExpertDataMapper. That was probably not done for several reasons, mostly tied to simplicity. If you have a separate class that should do work within the same transaction, you have to pass the transaction around. This in itself is not terrible, but it introduces more questions about how to make the implementation architecture-independent. If you just pass the Transaction around, you're coupled to vanilla ADO.NET, and can't upgrade later to an ORM like MSEF, NHibernate, Linq2SQL, etc. So you need a UnitOfWork pattern, which allows you to hide the actual Transaction or Session or DataContext or whatever in the Repository. By now, this relatively simple code snippet is now two full class definitions with plenty of stuff.</p> <p>To avoid all this for the purposes of illustrating one Expert, they just put the code to save Cases inside the Expert. This basically makes the assumption that a Case will always be referenced as a child of an Expert, and so it wouldn't be worth it to sever the functionality into something that can be reused. KISS. This assumption may be true; if not, it is left as an exercise to the reader to refactor that logic out into a helper.</p> <p>On the second point, you are also correct, and there really is no way around it. Every row created from data the SQL Server can't yet know about must be inserted one row at a time. You MIGHT somehow be able to set up a bulk insert, but I can guarantee that's more trouble than its worth until you get into the thousands of records. Any ORM you'd use would result in the same SQL.</p> <p>On not using an ORM: With a sufficiently complex domain/data model, if you do not use a prefab ORM, you will end up rolling your own if you want it to conform to design methodologies like SOLID.</p>
    singulars
    1. This table or related slice is empty.
    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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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