2

I have no clue how i can get an existing object structure based on the following classes (simplified) into a database using Entity Framework (EF is a constraint, i have to use it).

public abstract class WahWahProperty
{
  public string Name { get; set; }
  public abstract Type PropertyType { get; }
}

// ----------------

public class WahWahProperty<T> : WahWahProperty
{
  public T Value { get; set; }

  public override Type PropertyType
  {
    get { return typeof(T); }
  }
}

// ----------------

public class WahWahContainer
{
  public List<WahWahContainer> Children { get {...}; }
  public List<WahWahContainer> Parents { get {...}; } // multiple "Parents" allowed
  public List<WahWahProperty> Properties { get {...}; }
  //... some more props here ...
}

Any ideas?

JRoppert
  • 5,854
  • 5
  • 32
  • 37

1 Answers1

2

The EF doesn't support generic Entity types (which seems to be what you are doing).

Although we have made a change in EF 4.0 (not in Beta1) so you will be able to use a non-generic class derived from a generic class as an Entity.

Anyway hope this helps

Alex

Program Manager Entity Framework Team

Entity Framework Tips

Alex James
  • 20,874
  • 3
  • 50
  • 49
  • Will that be in Beta 2? Can you pint me to some more info about that? – JRoppert Oct 16 '09 at 12:36
  • Yeah that is a Beta2 thing. I was one of the people who drove getting this capability in the product but there isn't anything that describes this yet. – Alex James Oct 16 '09 at 15:05
  • Thanks Alex, looking forward to seeing this soon, might help with some re-use with relation stuff like generalizing associations between entities (implementing one to many in application). – Jason Nov 19 '09 at 15:56