title: In MS MVC, are Poco classes to be defined in the Models namespace but outside of a repository class?
body: <p>I think I am very close to assembling an MVC repository correctly but just falling apart at the fringe.  I created an MVC project with a repository and am returning data successfully, but not accurately as it pertains to DDD.  Please tell me where I am incorrect in terms of strict DDD assembly.  I guess if the topics are too wide, a book suggestion would be fine.  I hope that I am specific enough in my question.</p>
  
  <p>This was one question but I separated them for clarity: Do you create a single namespace for all repository classes called MyStore.Models?  Create a repository class for each entity like Product within the Models namespace?  Do you put the Pocos in their own classes in the Models namespace but not part of the Repository class itself?</p>
  
  <p>I am currently using Pocos to cut out entities from Linq statements, returning groups of them within IQueryable wrappers like so.  I guess here you would somehow remove the IQueryable and replace it with some type of Lazy load?  How do you lazy load without being dependent on the original Linq to Sql?</p>
  
  <pre><code>public IQueryable&lt;Product&gt; GetProducts(...) {
  return (from p in db.Products
          where ...
          select new myProductPoco {  // Cut out a Poco from Linq
              ID = p.ID,
              Name = p.Name,
              ...
          });
  }
  </code></pre>
  
  <p>Then reference these in MVC views within the inherit page directive:</p>
  
  <pre><code>System.Web.Mvc.ViewPage&lt;IQueryable&lt;MyStore.Models.Product&gt;&gt;
  </code></pre>
  
  <p>However, the nested generics looks wrong.  I assume this requires a re-factor.  Where do you define View Model classes that contain references to Entities?  Within the controller class (nested class)?</p>