Пример #1
0
 public static Task <T> FirstOrDefaultAsync <T>(this IQueryable <T> source, Expression <Func <T, bool> > predicate)
 {
     if (IsInUnitTest)
     {
         return(Task.FromResult(source.FirstOrDefault(predicate)));
     }
     return(QE.FirstOrDefaultAsync(source, predicate));
 }
Пример #2
0
 public static Task <T> FirstOrDefaultAsync <T>(this IQueryable <T> source)
 {
     if (IsInUnitTest)
     {
         return(Task.FromResult(source.FirstOrDefault()));
     }
     return(QE.FirstOrDefaultAsync(source));
 }
        public static Task <T> FirstOrDefaultAsync <T>(this IQueryable <T> source, Expression <Func <T, bool> > predicate)
            where T : class
        {
            if (source is EntitySet <T> )
            {
                source = (source as EntitySet <T>).DbSet;
            }

            return(Extensions.FirstOrDefaultAsync(source, predicate));
        }
Пример #4
0
        public static async Task <T> FirstOrDefaultAsync <T>(this IQueryable <T> source, Expression <Func <T, bool> > predicate)
            where T : class
        {
            if (predicate == null)
            {
                throw new ArgumentNullException($"The {nameof(predicate)} can not be null.");
            }

            if (source is EntitySet <T> )
            {
                source = (source as EntitySet <T>).DbSet;
            }

            T result = await Extensions.FirstOrDefaultAsync(source, predicate).ConfigureAwait(continueOnCapturedContext: false);

            return(result);
        }