ASP.NET MVC TASK MANAGER one-to-many relationship -
i trying learn asp.net mvc have started build small application - task manager based on tutorials on internet (mvc music store, nerd dinner, etc ...). ive got stuck while trying define actionresult method in controller.
i have model, defining activities. each activity can have several tasks.
activity 1 (each activiy has got several tasks (task 1, task 2, etc)) activity 2 activity 3 activity n
question:
i ask definition of actionresult method, return view list of tasks related selected activity.
picture here: http://sdrv.ms/z46nze
the problém is, not able define method one-to-many relationship.
whole project here in skydrive folder: http://sdrv.ms/zicbqi
please help.
in model, have following classes , context class generated mvcscaffolding:
using system; using system.collections.generic; using system.linq; using system.web; using system.componentmodel.dataannotations; using system.componentmodel.dataannotations.schema; namespace task3.models { public class task { public int taskid { get; set; } public string name { get; set; } public int activityid { get; set; } public datetime? createdon { get; set; } public datetime? modifiedon { get; set; } public string pn { get; set; } public string result { get; set; } public string todo { get; set; } public string responsibleperson { get; set; } public datetime? duedate { get; set; } public int? taskpriority { get; set; } public string taskstatus { get; set; } public virtual activity activity { get; set; } } public class activity { public int activityid { get; set; } [required] public string name { get; set; } public string activitytype { get; set; } public int? activitypriority { get; set; } public string activitystatus { get; set; } public virtual icollection<task> tasks { get; set; } } }
thank much!
best regards
jaroslav plavec
change
public virtual icollection<task> tasks { get; set; }
to
public list<task> tasks { get; set; }
remember has serializable, icollection not, list is.
Comments
Post a Comment