Compare commits
2 Commits
9f2a13df6f
...
6717aa37ab
| Author | SHA1 | Date | |
|---|---|---|---|
| 6717aa37ab | |||
| bf418e986b |
@@ -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;
|
||||
@@ -21,6 +19,26 @@ namespace DigitalData.Core.Infrastructure
|
||||
{
|
||||
#endif
|
||||
|
||||
public class DbRepository<TDbContext> where TDbContext : DbContext
|
||||
{
|
||||
protected internal readonly TDbContext Context;
|
||||
|
||||
public DbRepository(TDbContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public int ExecuteSqlRaw([NotParameterized] string sql, params object[] parameters)
|
||||
{
|
||||
return Context.Database.ExecuteSqlRaw(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteSqlInterpolated(FormattableString sql)
|
||||
{
|
||||
return Context.Database.ExecuteSqlInterpolated(sql);
|
||||
}
|
||||
}
|
||||
|
||||
public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbContext : DbContext where TEntity : class
|
||||
{
|
||||
protected internal readonly TDbContext Context;
|
||||
@@ -44,6 +62,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)
|
||||
{
|
||||
|
||||
@@ -41,18 +41,22 @@
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.32" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.32" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.20" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user