combined cache provider for azure in c# -


for website have in azure cloud , work on, need implement "hybrid" cache.

meaning, website displays table of records db, , provides option either add new records or update existing ones. reads, need implement in-process cache, , writes (adding, updates) need have out-of-process cache.

i'm pretty new @ c# , azure. i'll glad begin with...

currently, use simple sql commands display, add or update:

protected void page_load(object sender, eventargs e)         {             if (page.ispostback)                 gridview1.databind(); }  protected void button1_click(object sender, eventargs e)         {             string insertcommand = "insert [students] ([student_name], [gpa]) values (@student_name, @gpa)";             string connstring = sqlazuredatasource.connectionstring;             using (sqlconnection conn = new sqlconnection(connstring))             {                 using (sqlcommand comm = new sqlcommand())                 {                     comm.connection = conn;                     comm.commandtext = insertcommand;                     comm.parameters.addwithvalue("@student_name", textbox1.text);                     comm.parameters.addwithvalue("@gpa", textbox2.text);                      try                     {                         conn.open();                         comm.executenonquery();                         this.databind();                     }                     catch (sqlexception ex)                     {                         console.writeline(ex.stacktrace);                     }                 }             }         } // similar update 

i'll appreciate given

thanks

link on how use azure caching. here link on windows server appfabric

architecturally, caching have implemented level above sql query.

btw, if new c# , developing web based app may suggest @ entity framework, nice mvvm pattern , maybe use asp mvc. entity framework alone save lot of time , code more maintainable.

edit

the right way add items cache - here example. let assume have table called employees. can create dataset , fill in results of query dataset. can save in cache.

again, please see entity framework allow ease. building on above example, ef allow create class employee in c# , and fill in results of query class.

the cache code in both cases sit on top of sql query. create separate class getemployeedetails() method. issue call getemployeedetails() hits cache see if data exists. if not, hits sql.

move out page_load own classes.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -