Let say I have general table of records (I'm using EF code first) and there can be many different types of details that can be used with this table:
class Record{
int Id,
int TypeOfDetails, // int enum Type1, Type2
string Details, //string with json content
string Attribute 1,
string Atribute 2,
...
}
class DetailsType1{
string InternalAtribute1,
....
}
I decided to use Json to serialize Details objects into database field. This allows to flexible work with different Details without changing DB schema.
Working with one records is easy, I know type of the Details object, so I can serialize and deserialize.
But how to efficiently retrieve multiple records and be able to reference details in in MVC ? Let say I do this:
var results = await context.Record.Where(..).ToAsyncList();
I would want to be able to do this in my .cshtml:
@Html.DisplayFor(modelItem => item.Record.Details.InternalAtribute1)
Essentially it would be doing deserialization on the fly..
Alternatively if something like that is possible in AngularJS it would also be helpful.
Let me know if I make myself clear with my question.
Details
field?