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.
This commit is contained in:
2025-12-18 13:21:35 +01:00
parent 9f2a13df6f
commit bf418e986b
2 changed files with 10 additions and 3 deletions

View File

@@ -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<TEntity> Sql([NotParameterized] string sql, params object[] parameters)
{
return Entities.FromSqlRaw(sql, parameters);
}
#region Create
public virtual async Task<TEntity> CreateAsync(TEntity entity, CancellationToken cancel = default)
{