EF6 alpha Async Waiting while saving an object / import function?

I would like to apply the new async wait function to stored procedures / function imports imported into my Entity model, but so far I have not been able to use EF6 alpha.

Is it possible to call any of the new Async methods in Entity Function Import (which calls an SQL-stored procedure) that returns a collection of complex type in EF6 alpha2 (or nightly since 20211)? eg.

private async Task<IList<Company>> getInfo (string id)
{
    using (CustomEntity context = new CustomEntity())
    {
        var query = await context.customStoredProcedure(id).ToListAsync();
        // ".ToListAsync()" method not available on above line

        // OR ALTERNATIVELY
        var query = await (from c in context.customStoredProcedure(id)
                           select new Company
                           {
                              Ident = c.id,
                              Name = c.name,
                              Country = c.country,
                              Sector = c.sector, 
                              etc. etc....
                           }).ToListAsync();
        // ".ToListAsync()" method or any "...Async" methods also not available this way

        return query;
    }
}

"ToListAsync", or any of the new modified asynchronous methods, does not seem to be available for the aforementioned Object Store / Import Functions; only standard ToList or AsNumerable methods, etc. are available.

(http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6), , DLL EF6, EF5, using. , . (.NET Framework 4.5)

, async, , , , , , Entity, (context.SomeTable), intellisense.

async JSON, .

- ? / Entity? .

+5
2

. , . EF6.1 + , . .

static async Task<List<T>> ToListAsync<T>(this ObjectResult<T> source)
{
    var list = new List<T>();
    await Task.Run(() => list.AddRange(source.ToList()));
    return list;
}

6 EF, , ObjectResult<T> IDbAsyncEnumerable<T>, IDbAsyncEnumerable. ToListAsync<T>(this IDbAsyncEnumerable<T> source) , LINQ.

Edit ObjectResult , null. if (source == null) return new List<T>();, .

+4

, , . APM, .

:

//declare the delegate
private delegate MyResult MySPDelegate();

// declare the synchronous method
private MyResult MySP()
{
    // do work...
}

:

// wraps the method in a task and returns the task.
public Task<MyResult> MySPAsync()
{
    MySPDelegate caller = new MySPDelegate(MySP);
    return Task.Factory.FromAsync(caller.BeginInvoke, caller.EndInvoke, null);
}

async, :

var MyResult = await MySPAsync();

(3) . ; .

0

All Articles