title: MVC4 : Interface object in Model
body: <p>I'm quite new about MVC. I have the following Model classes:</p>
  
  <pre><code>public class Store
  {   
    public PriceList PriceListInfo { get; set; }
    public IStore storeData;
  }    
  
  public class PriceList
  {
    public int id { get; set; }
    public string codice { get; set; }
  }    
  
  public interface IStore
  {
   [...]
  }    
  
  public class Silo2Store : IStore
  {
    public int S2 { get; set; }
    public int S3 { get; set; }
  }
  </code></pre>
  
  <p>And i want use this model in my view:</p>
  
  <pre><code>@model Store
  
  @Html.TextBoxFor(model =&gt; ((Silo2Store)Model.storeData).S3) 
  </code></pre>
  
  <p>The corresponding Controller method is:</p>
  
  <pre><code>public ActionResult Customer()
  {
      using (Store t = (Store)Session["Store"])
      {
          if (t.PriceListInfo == null)
          {
              t.PriceListInfo = new PriceList();
          }
          t.PriceListInfo.codice = "XXX";
          return View(t);
      }
  }
  </code></pre>
  
  <p>And I'd like to retrieve the model in my Controller:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Customer(Store modelStore)
  {
      var test = ((Silo2Store)Model.storeData).S3;
  }
  </code></pre>
  
  <p>but <code>Model.storeData</code> attribute isn't initialized in my view, it's <code>null</code>. Then, I can't  retrieve the value in my controller.</p>
  
  <p>Should I change my model in anyway?</p>