Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The short answer is <a href="http://codebetter.com/jeremymiller/2009/01/08/choosing-the-constructor-function-in-structuremap-without-attributes/" rel="nofollow">this post by the creator of Structuremap</a>.</p> <p>The long answer is regarding the structure you have in that piece of code. In my view, a command is by definition a "class" that does something to an "entity", i.e it modifies the class somehow. Think CreateNewProductCommand.</p> <p>Here you are using commands for querying, if I'm not mistaken. You also have a bit of a separation of concern issue floating around here. The command posted defines what to do and how to do it, which is to much and you get that kind of Service location you're using in </p> <pre><code>private Repository&lt;IProduct, Product&gt; GetProductRepository() { return ObjectFactory.GetInstance&lt;Repository&lt;IProduct, Product&gt;&gt;(); } </code></pre> <p>The way I'd structure commands is to use CreateProductCommand as a data contract, i.e it only contains data such as product information. Then you have a CreateProductCommandHandler which implements <code>IHandles&lt;CreateProductCommand&gt;</code> with a single method <code>Handle</code> or <code>Execute</code>. That way you get better separation of concern and testability.</p> <p>As for the querying part, just use your repositores directly in your controller/presenter, alternatively use the <a href="http://ayende.com/blog/3955/repository-is-the-new-singleton" rel="nofollow">Query Object pattern</a> </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.
 

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