From b7c6477ec2c4e36aa60b5ab1a709b72f61c9faf7 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 25 Jul 2025 17:01:11 +0200 Subject: [PATCH] =?UTF-8?q?feat(repo):=20Hinzuf=C3=BCgen=20von=20ProfileOb?= =?UTF-8?q?jRepository=20zum=20Abrufen=20von=20Profilobjekten=20=C3=BCber?= =?UTF-8?q?=20eine=20SQL-Funktion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/ProfileObjRepository.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/WorkFlow.Infrastructure/Repositories/ProfileObjRepository.cs diff --git a/src/WorkFlow.Infrastructure/Repositories/ProfileObjRepository.cs b/src/WorkFlow.Infrastructure/Repositories/ProfileObjRepository.cs new file mode 100644 index 0000000..b8db9a2 --- /dev/null +++ b/src/WorkFlow.Infrastructure/Repositories/ProfileObjRepository.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore; +using WorkFlow.Domain.Entities; + +namespace WorkFlow.Infrastructure.Repositories; + +/// +/// Repository implementation for retrieving entities from the database. +/// +public class ProfileObjRepository +{ + private readonly WFDBContext _context; + + /// + /// Initializes a new instance of the class. + /// + /// The database context used for accessing profile data. + public ProfileObjRepository(WFDBContext context) + { + _context = context; + } + + /// + /// Retrieves the list of associated with a given user ID and profile ID by calling a database function. + /// + /// The unique identifier of the user whose profile is to be retrieved. + /// The unique identifier of the profile whose object is to be retrieved. + /// Propagates notification that operations should be canceled. + /// + /// A task that represents the asynchronous operation. The task result contains the object if found; otherwise, null. + /// + /// + /// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues. + /// + public async Task> ReadAsync(int userId, int profileId, CancellationToken cancel = default) + => await _context.Objects + .FromSqlRaw("SELECT * FROM [FNMWF_GET_PROFILE_OBJECTS] ({0}, {1})", userId, profileId) + .ToListAsync(cancel); +} \ No newline at end of file