views:

196

answers:

1

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?

+2  A: 

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
Will that be in Beta 2? Can you pint me to some more info about that?
JRoppert
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
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