From bf418e986bb5b8853094441f4360babf013b0936 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 18 Dec 2025 13:21:35 +0100 Subject: [PATCH] Add Sql method to DbRepository and EFCore.Relational refs Added a Sql method to DbRepository for executing raw SQL queries via FromSqlRaw. Included Microsoft.EntityFrameworkCore.Relational package references for all target frameworks to support this functionality. Cleaned up unused using directives. --- DigitalData.Core.Infrastructure/DbRepository.cs | 9 ++++++--- .../DigitalData.Core.Infrastructure.csproj | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs index a0a2f42..63a06ee 100644 --- a/DigitalData.Core.Infrastructure/DbRepository.cs +++ b/DigitalData.Core.Infrastructure/DbRepository.cs @@ -1,11 +1,9 @@ using AutoMapper; using DigitalData.Core.Abstraction.Application.Repository; -using DigitalData.Core.Abstractions.Interfaces; using DigitalData.Core.Infrastructure.Factory; using Microsoft.EntityFrameworkCore; using System.Linq.Expressions; -using Microsoft.Extensions.DependencyInjection; - +using Microsoft.EntityFrameworkCore.Query; #if NETFRAMEWORK using System.Collections.Generic; using System; @@ -44,6 +42,11 @@ namespace DigitalData.Core.Infrastructure Mapper = mapper; } + public IQueryable Sql([NotParameterized] string sql, params object[] parameters) + { + return Entities.FromSqlRaw(sql, parameters); + } + #region Create public virtual async Task CreateAsync(TEntity entity, CancellationToken cancel = default) { diff --git a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj index a4d882e..c6eb76b 100644 --- a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj +++ b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj @@ -41,18 +41,22 @@ + + + +