c# - SQL(SQLite) and backwards compatibility -


a beginner in sql/db here- i'm designing universal windows app db might come in handy, i'm reading on sql/sqlite , i'm wondering- how backwards compatibility (classes/tables wise) works? suppose add or remove property class i've been using base table- still able interact old- class data , cast updated class? how 1 go monitoring added/ removed properties while querying db?

thank time.

edit: scenario- if i've got user 2 properties- 'id', 'name'.

public class user { public int id {get; set; } pubic string name {get; set;} } 

and i've built application 'users' db , i'm using while. then, add property user- class. suppose it's 'age'. can add new property original 'user' class , still able access original users table with-

var user = dbconnection.table<user>().where(x => x.id == tid).firstordefault(); 

obviously, 1 option keep original user , create class userex have original properties + age. grab 'user's, port them userex , save new table.

this seem bit cumbersome each added/ removed property though

can add new property original 'user' class , still able access original users table ?

var user = dbconnection.table<user>().where(x => x.id == tid).firstordefault(); 

does adding property user class update underlying sqllite table? need extend class maintain compatibility.

public class user     {         public int id {get; set; }         public string name {get; set;}          public user getuser(int tid)         {             var user = dbconnection.table<user>().where(x => x.id == tid).firstordefault();             id = user.id;             name = user.name;             //age = user.age; // not possible         }             }      public class detaileduser:user     {         public int age { get; set; }             public detaileduser getuser(int tid)         {             var user = dbconnection.table<user>().where(x => x.id == tid).firstordefault();             base.id = user.id;             base.name = user.name;             //age = user.age; // not possible         }          public detaileduser getdetaileduser(int tid)         {             var user = dbconnection.table<detaileduser>().where(x => x.id == tid).firstordefault();             base.id = user.id;             base.name = user.name;             age = user.age;         }     } 

the obvious 'cumbersome' process outlined valid option. either way when changing data layer in application there consequences.

two things come mind, 1 in android sqllite has onupgrade function whey can put "cumbersome" data layer upgrade logic.. or use nosql solution mongodb data layer more forgiving structure of underlying records (ymmv).

finally better plan data layer structure fewer times run kind of issue.

i hope of help.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -