none
Async methods missing in my LinQ method calls. RRS feed

  • Question

  • I tried writing the following short query code in my program (EF6 .NET 451 with MVVM Light) to see how to access asynchronously the db, however, I DON'T have ANY Async methods except SaveChangesAsync.  That is, I don't have for example FirstOrDefaultAsync()???

    I tried the following code (my Intellisense that shows methods after my Where() clause shows absolutely NO async methods):

    private static async Task<Student> GetStudent()
    {
        Student student = null;
    
        using (var context = new SchoolDBEntities())
        {
            Console.WriteLine("Start GetStudent...");
                  
            student = await (context.Students.Where(s => s.StudentID == 1).FirstOrDefaultAsync<Student>());
                
            Console.WriteLine("Finished GetStudent...");
                   
        }
    
        return student;
    }


    MarcinMR

    Monday, March 7, 2016 6:44 PM

Answers