Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>without any code from the controllers it's difficult to say, but a very common problem with Entity Framework is forgetting to use the <code>.Include()</code> extension method. e.g. <code>var cameras = db.Cameras.Include(c =&gt; c.Features).ToList();</code> which would give you a list of Cameras and associated features to pass to your view.</p> <p>Also, if you add the virtual keyword to your Navigation Properties, Entity Framework can perform "Lazy Loading" where it automatically loads the associated items the first time they are accessed (server side). In general, most Navigation Properties would also be defined as generic. e.g.:</p> <pre><code>public class Feature { public int ID { get; set; } public string Desc { get; set; } public virtual ICollection&lt;Camera&gt; Cameras { get; set; } } public class Camera { public int ID { get; set; } public string ModelName { get; set; } public virtual ICollection&lt;Feature&gt; Features { get; set; } } </code></pre> <p>This allows you access to a much larger array of extension methods for filtering and sorting. <code>IEnumerable</code> describes behavior, while <code>List</code> is an implementation of that behavior. When you use <code>IEnumerable</code>, you give the compiler a chance to defer work until later, possibly optimizing along the way. If you use <code>List</code> you force the compiler to reify the results right away. In your case, using ICollection vs IEnumearable is necessary, since IEnumerable only allows list browsing, while ICollection defines a CopyTo method used by Entity Framework Internally.</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. 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