c# - How can I separate this Entity Framework model to prevent memory errors? -
i trying work set of data legacy app , move mssql database. created app in c# ef manage data. class structure represents old c style arrays legacy app class order.
these 3 main classes. other properties involved have included main form , memory hog (accountdetails) here. when structure built out has 1 simulation - 50 100 accounts , each account has between 1000 or more account detail objects.
if add whole structure @ once - , save changes memory error. how can add accountdetail objects , keep linked 1 object structure? can add them separately (i have id's , 1 many's setup though not details included here).
public class simulation { public string name { get; set; } public list<account> accounts { get; set; } } public class account { public int id { get; set; } public string name { get; set; } public int type { get; set; } public list<accountdetail> details { get; set; } } // trouble in here.... public class accountdetail { public int id { get; set; } public int type { get; set; } public int scenario { get; set; } public double m01 { get; set; } ..... class has 60 doubles 5 years of payments .... public double m60 { get; set; } } thanks,
k.
well, since have ids. following.
create simulation object , populate non-navigation properties (so ints, doubles etc.) save changes.
create list of accounts , populate non-navigation properties, make sure simulationid (or foreign key using link account simulation filled in). save changes.
create list of accountdetails, populate non-navigation properites, make sure accountid (or foreign key using link account details account filled in).
in entity framework, don't need objects in memory. it's foreign keys matter. can save memory saving 10 accounts @ time if want to. honest, haven't seen yet ef complaining memory, raises question... have set correctly?
Comments
Post a Comment