mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
optimization sql
This commit is contained in:
@@ -24,6 +24,7 @@ public class FriendshipsRepository : IFriendshipsRepository
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Requester)
|
||||
.Include(x => x.Addressee)
|
||||
.AsSplitQuery()
|
||||
.ToListOrThrowIfEmpty(new NotFoundException("Database is empty"));
|
||||
}
|
||||
|
||||
@@ -33,6 +34,7 @@ public class FriendshipsRepository : IFriendshipsRepository
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Requester)
|
||||
.Include(x => x.Addressee)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(x => x.Id == id)
|
||||
?? throw new NotFoundByKeyException<Guid>(id, "Friendship with given id was not found");
|
||||
}
|
||||
@@ -43,6 +45,7 @@ public class FriendshipsRepository : IFriendshipsRepository
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Requester)
|
||||
.Include(x => x.Addressee)
|
||||
.AsSplitQuery()
|
||||
.Where(x => x.RequesterId == userId)
|
||||
.ToListOrThrowIfEmpty(new NotFoundByKeyException<Guid>(userId, "Friendship with given user id was not found"));
|
||||
}
|
||||
@@ -81,11 +84,7 @@ public class FriendshipsRepository : IFriendshipsRepository
|
||||
);
|
||||
|
||||
if (rowsAffected == 0)
|
||||
throw new NotFoundByKeyException<Guid>(friendship.Id);
|
||||
}
|
||||
catch (NotFoundByKeyException<Guid> ex)
|
||||
{
|
||||
throw new UpdateException($"Not found friendship by given id {friendship.Id}", ex);
|
||||
throw new UpdateException($"Not found friendship by given id {friendship.Id}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user