entity framework - How to properly create C# class with a list of weekly open hours property -


i feel going obvious many of you, research led me nowhere. i'm trying build class create objects list of properties one:

public class myobject     {         [key]         public int id { get; set; }         public string title { get; set; }         public list<openhours> openhours { get; set; }         public filter filters { get; set; }      } 

i want openhours object store list of daily hours accessible doing myobject.openhours[index].property.

i'm getting error openhours object not have defined key, don't want in database different entity, want store properties same way if listed each of weekday's properties directly in myobject class.

here openhours class:

public class openhours {     public dayofweek day { get; set; }     public string starttime { get; set; }     public string endtime { get; set; } } 

i want each of "myobject" objects have unique openhours values, not want create id it. missing in syntax, or bad logic so?

thanks in advance answers!

edit: answered , deleted answer afterwards, can't mark right answer, solution add [complextype] class :

[complextype] public class openhours {     public dayofweek day { get; set; }     public string starttime { get; set; }     public string endtime { get; set; } } 

if each entry going unique make compound primary key if not want introduce id. make properties primary key. less efficient in db terms creating id primary key though.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -