I have a class like this:
public class GeneralClass
{
public int Id {get; set;}
public string Name {get; set;}
}
which is a pretty generic class. I also have a derived class like this:
public class DerivedClass: GeneralClass
{
public int SpecificProperty {get; set;}
public string AnotherSpecificProperty {get; set;}
public bool BooleanSpecificProperty {get;set;}
}
The problem is, I can have lots of derived classes (more than 10) in my app, that´s why inheritance in a database IS NOT AN OPTION.
The solution I came up with is to have GeneralClass
as a table, with an XML column containing the specific properties.
Something like this:
CREATE TABLE
General(Id int primary key,
Name nvarchar(50),
SpecificProperties xml);
where the specific properties contain the properties of the derived class.
The question is: How can I SAVE and QUERY this xml column using Entity Framework, and deserialize the xml into the properties?