Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use an ORM to map the command inheritance to database. For example you can use "Table per Hierarchy" technique provided by the ORMs (eg: Entity Framework, nHibernate, etc). ORM will instantiate the correct subclass when you retrieve them.</p> <p>Here's an example of doing it in Entity Framework Code first</p> <pre><code>abstract class Command : ICommand { public int Id {get;set;} public abstract void Execute(); } class CommandA : Command { public int X {get;set;} public int Y {get;set;} public override void Execute () { ... } } class CommandB : Command { public string Name {get;set;} public override void Execute () { ... } } </code></pre> <p>Refere <a href="http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-code-first-walkthrough.aspx" rel="noreferrer">EF 4.1 Code First Walkthrough</a> to configure this model with EF.</p> <p>If your commands takes drastically different set of parameter you can consider using "Table per Type" inheritance modeling. Here you will have pay some significant performance penalty because of lot of Unions and table joins involved in this.</p> <p>Alternative approach would be to store the Command parameters as a XML configuration where you (de)serialize manually. This way you can keep all your commands in a single table without sacrificing performance. Again this has a drawback where you can not filter using the command parameters.</p> <p>Each approach has its Pros and Cons. You can choose the strategy which suits your requirements.</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.
    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