Database Reference
In-Depth Information
modelBuilder.Entity<AssociateSalary>().HasKey(x => x.SalaryId);
base.OnModelCreating(modelBuilder);
}
}
Listing 3-3 demonstrates how we can leverage the new Entity Framework Async methods to implement
asynchronous processing for the queries that remove, load, and fetch data.
Listing 3-3. Asynchronously Processing Entity Framework Queries
private static void Main()
{
var asyncTask = EF6AsyncDemo();
foreach (var c in BusyChars())
{
if (asyncTask.IsCompleted)
{
break;
}
Console.Write(c);
Console.CursorLeft = 0;
Thread.Sleep(100);
}
Console.WriteLine("\nPress <enter> to continue...");
Console.ReadLine();
}
private static IEnumerable<char> BusyChars()
{
while (true)
{
yield return '\\';
yield return '|';
yield return '/';
yield return '-';
}
}
private static async Task EF6AsyncDemo()
{
await Cleanup();
await LoadData();
await RunForEachAsyncExample();
await RunToListAsyncExampe();
await RunSingleOrDefaultAsyncExampe();
}
 
Search WWH ::




Custom Search