Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't think that any entity framework mapping (especially if we talk about fluent / code-first) is able to map that directly - I just tested approach with inheritance and it didn't work. EF is heavily dependent on the way how database is designed. In your case you will most probably end with something like this:</p> <pre><code>public class Profile { public int ProfileId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public virtual ICollection&lt;ProfileProperty&gt; Properties { get; set; } } public class ProfileProperty { public Guid PropertyId { get; set; } public int ProfileId { get; set; } public int PropertyId { get; set; } public virtual Profile Profile { get; set; } public virtual Property Property { get; set; } } public class Property { public int LookupId { get; set; } public int CategoryId { get; set; } public string Description { get; set; } } </code></pre> <p>Now if you want to have properties like Degrees you will have to add non mapped property like:</p> <pre><code>public IEnumerable&lt;Property&gt; Degrees { get { return Properties.Where(p =&gt; p.Property.CategoryId == 1) .Select(p =&gt; p.Property); } </code></pre> <p>It will work only for reading but not for modifying properties. For modification you will need more complex logic to build correct structure inside real <code>Properties</code> collection.</p> <p>Even support of enums planned to .NET 4.5 would not solve it. Enums will support only representing single integral column as enum but in your case you need to decompose many to many relation to many enums.</p>
 

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