| | |
| | | using Microsoft.EntityFrameworkCore; |
| | | using System.Linq.Dynamic.Core; |
| | | using System.Linq.Expressions; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | |
| | |
| | | return (await GetQueryableAsync()) |
| | | .Where(x => !x.IsDeleted).IncludeDetails(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据条件获取叫料单表列表 |
| | | /// </summary> |
| | | /// <param name="whereConditions"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default) |
| | | { |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails() |
| | | .WhereIf(whereConditions != null, whereConditions) |
| | | .Where(x => !x.IsDeleted) |
| | | .OrderByDescending(x => x.CreationTime) |
| | | .ToListAsync(GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据条件获取单个叫料单表 |
| | | /// </summary> |
| | | /// <param name="whereConditions"></param> |
| | | /// <param name="isMultipleThrowException">是否查询出多条就报错</param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="UserFriendlyException"></exception> |
| | | public async Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool isMultipleThrowException = false, CancellationToken cancellationToken = default) |
| | | { |
| | | if (isMultipleThrowException) |
| | | { |
| | | var entitys = await (await GetDbSetAsync()) |
| | | .IncludeDetails() |
| | | .WhereIf(whereConditions != null, whereConditions) |
| | | .Where(x => !x.IsDeleted) |
| | | .OrderByDescending(x => x.CreationTime) |
| | | .ToListAsync(GetCancellationToken(cancellationToken)); |
| | | if (entitys?.Count > 1) |
| | | { |
| | | throw new UserFriendlyException("查询到多条记录"); |
| | | } |
| | | return entitys?.FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails() |
| | | .WhereIf(whereConditions != null, whereConditions) |
| | | .Where(x => !x.IsDeleted) |
| | | .OrderByDescending(x => x.CreationTime) |
| | | .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
| | | } |
| | | } |
| | | } |