Example #1
0
        public static async Task <T> FirstOrDefaultNoLockAsync <T>(this IOrderedQueryable <T> query, Expression <Func <T, bool> > predicate)
        {
            using (
                var scope = new TransactionScope(TransactionScopeOption.Required,
                                                 new TransactionOptions()
            {
                IsolationLevel = IsolationLevel.ReadUncommitted
            },
                                                 TransactionScopeAsyncFlowOption.Enabled))
            {
                var toReturn = await query.FirstOrDefaultAsync(predicate);

                scope.Complete();
                return(toReturn);
            }
        }
        public static async Task <CarModel> FindModelByIdAsync(this IOrderedQueryable <CarModel> models, int id)
        {
            CarModel carModel = await models.FirstOrDefaultAsync(cm => cm.Id == id);

            return(carModel);
        }
 public static async Task <Car> FindCarByIdAsync(this IOrderedQueryable <Car> cars, int id)
 {
     return(await cars.FirstOrDefaultAsync(c => c.Id == id));
 }
 internal static async Task <CarColor> FindColorByIdAsync(this IOrderedQueryable <CarColor> colors, int id)
 {
     return(await colors.FirstOrDefaultAsync(c => c.Id == id));
 }
 public static async Task <CarBrand> FindBrandByIdAsync(this IOrderedQueryable <CarBrand> brands, int id)
 {
     return(await brands.FirstOrDefaultAsync(b => b.Id == id));
 }
Example #6
0
 public async Task <T> SingleAsync(IOrderedQueryable <T> queryable) => await queryable.FirstOrDefaultAsync();