entity framework - C# unit of work bad implementation -
i tried implement unit of work sqlce database. works correctly except 1 thing.
i have scenario patient can perform different sessions , each session based on specific test. these implementations:
public class patient { public int id { get; set; } public byte[] identificationcode { get; set; } public string sex { get; set; } public virtual list<session> sessions { get; set; } } public class session { public int id { get; set; } public guid unique { get; set; } public datetime datetime { get; set; } public virtual patient patient { get; set; } public virtual test test { get; set; } public virtual list<videoexerciseresult> videosessionresults { get; set; } public virtual list<audioexerciseresult> audiosessionresults { get; set; } } public class test { public int id { get; set; } public string name { get; set; } public virtual list<session> sessions { get; set; } }
when perform test data saved , can directly go see results session.
but when run again application , load session results , test in session appear null (while patient, id , unique have correct values).
private void getsessiondata() { // list<test> templist = new list<test>(uow.tests.getall()); // list<audioexerciseresult> templist1 = new list<audioexerciseresult>(uow.audiosessionsresults.getall()); switch (selectedsession.test.name) {
and discovered loading list of tests , results database before calling session object make values of test , results inside session object correctly appear.
there don't understand in world of db. can clarify me why have load list of values db?
is wasn't clear explain more precisely...
Comments
Post a Comment