c# - ADO.net Data Model Best Practice -


i've been working time ado.net data models (in asp.net). i'm not sure, use correctly.

for example, have model, "sqlentities.edmx" , try simplify access. created class called "eh" (for entity helper), kinda looks this

private static class eh {     private static sqlentities _sql = new sqlentities();      public static list<user> users     { { return _sql.users.tolist(); } }      public static void save(this object o)     {         dbset entities = _sql.set(o.gettype());         entities.add(o);         _sql.savechanges();     }      public static void delete(this object o)     {         dbset entities = _sql.set(o.gettype());         entities.remove(o);         _sql.savechanges();     }      public static void update()     {         _sql.savechanges();     } } 

first tried use it, needed it, like:

using(sqlentities sql = new sqlentities()) {     user utemp = new user()     {         name = "foo"     };     sql.users.add(utemp);     sql.savechanges(); } 

but had scope problem, switched static class.

my concerns are, method uses of servers memory space.

now question is: there better way use datamodel asp.

edit:

to make question more specific.

how use data model? solution practical?


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -