Skip to content

Commit

Permalink
fixing get single
Browse files Browse the repository at this point in the history
  • Loading branch information
MWClayson-NHS committed Feb 19, 2025
1 parent 274f388 commit c11a4ee
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ public DataServiceAccessor(DataServicesContext context, ILogger<DataServiceAcces

public async Task<TEntity> GetSingle(Expression<Func<TEntity, bool>> predicate)
{
var result = _context.Set<TEntity>().AsNoTracking().Where(predicate).ToList();
if (result.Count > 1)
{
throw new MultipleRecordsFoundException("Multiple Records where found for filter expression when only one was expected");
}
await Task.CompletedTask;
return result.SingleOrDefault();
var result = await _context.Set<TEntity>().AsNoTracking().SingleOrDefaultAsync(predicate);
return result;
}

public async Task<List<TEntity>> GetRange(Expression<Func<TEntity, bool>> predicates)
Expand Down

0 comments on commit c11a4ee

Please sign in to comment.