Skip to content
Marcin Sulecki edited this page Apr 7, 2017 · 2 revisions

Operacje asynchronicznie

Zapis danych

private static async Task SaveAlbumsAsyncTest()
       {
           using (var context = new MusicStoreContext())
           {
               var album = new Album();
               context.Add(album);
               await context.SaveChangesAsync();
           }
       }

Pobieranie danych

private static async Task GetAlbumsAsyncTest()
       {
           using (var context = new MusicStoreContext())
           {
               var albums = await context.Albums.ToListAsync();
 
               foreach (var album in albums)
               {
                   Console.WriteLine(album.Title);
               }
           }
       }

Connection String

  <add name="MyConnection"
         providerName="System.Data.SqlClient"
         connectionString="Data Source=SERVER/SQLSERVER;Initial Catalog=MyDb;Integrated Security=True;MultipleActiveResultSets=True;Asynchronous Processing=True"
         />

http://stackoverflow.com/questions/1642705/sql-server-connection-string-asynchronous-processing-true

Clone this wiki locally