No FindAsync() method on IDbSet

前端 未结 5 467
长发绾君心
长发绾君心 2021-01-01 12:43

Is there a reason that the FindAsync() method is omitted from the IDbSet interface? Find is part of the interface, it seems o

5条回答
  •  盖世英雄少女心
    2021-01-01 12:46

    Use this extension to solved the FindAsync problem

    /// 
    /// IDbSet extension
    /// 
    public static class IDbSetExtension
    {
        public static Task FindAsync(this IDbSet set, params object[] keyValues) 
            where TEntity : class
        {
            return Task.Run(() =>
            {
                var entity = set.Find(keyValues);
                return entity;
            });
        }
    }
    

提交回复
热议问题