c# - Entity Framework tree structure -
i have entity called field, looks like:
field.cs
class field { public int id { get; set; } public string name { get; set; } }
so fields simple list this:
1 : first name 2 : last name 3 : gender 4 : passport 5 : driver license 6 : issued 7 : expired
for each of entity called batch, want have arbitrary tree of fields, might this:
first batch
first name | last name | passport | gender | issued | expired |
or this:
second batch
first name | last name | gender | driver license | | issued | expired |
or other tree of fields, users type different values each field (some fields headings, passport, example)
so fields list of elements can reused, having sort of relationship between them based on batch. idea have batch entity like:
batch.cs
class batch { public int id { get; set; } public string fields { get; set; } // other data... }
where fields json tree "first batch":
{ 1, 2, 4: { 6, 7 }, 3 }
and second batch:
{ 1, 2, 3, 5: { 6, 7 } }
batches have more nested fields this:
| passport | | issued | expired | | month | year | month | year |
is best way store relationship in ef? should avoid json field , normalize data? if so, how go saving arbitrary tree relationship using ef model-first?
i suggest create 2 classes document , state
class batch { public int batchid { get; set; } public string bachfirstname{ get; set; } public string bachlastname{ get; set; } public string bachgender{ get; set; } public document bachdocument{ get; set; } } class document { public int docid { get; set; } public string docdesignation{ get; set; } public state docstate{ get; set; } } class state { public int id { get; set; } public string statedesignation{ get; set; } public date statedate{ get; set; } }
Comments
Post a Comment