db context
This commit is contained in:
commit
25f9679e83
388
.gitignore
vendored
Normal file
388
.gitignore
vendored
Normal file
@ -0,0 +1,388 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Nuget personal access tokens and Credentials
|
||||
nuget.config
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
64
PoweredSoft.DbContext.Core/DbContextQueryableExtensions.cs
Normal file
64
PoweredSoft.DbContext.Core/DbContextQueryableExtensions.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public static class DbContextQueryableExtensions
|
||||
{
|
||||
private static IQueryableExtensionService service;
|
||||
|
||||
public static void InitializeExtensionService(IQueryableExtensionService queryableService)
|
||||
{
|
||||
service = queryableService;
|
||||
}
|
||||
|
||||
public static IQueryable<T> Include<T, TProperty>(this IQueryable<T> source, Expression<Func<T, TProperty>> path)
|
||||
where T : class
|
||||
=> service.Include(source, path);
|
||||
|
||||
public static IQueryable AsNoTracking(this IQueryable source)
|
||||
=> service.AsNoTracking(source);
|
||||
|
||||
public static IQueryable<T> AsNoTracking<T>(this IQueryable<T> source) where T : class
|
||||
=> service.AsNoTracking(source);
|
||||
|
||||
public static IQueryable<T> Include<T>(this IQueryable<T> source, string path)
|
||||
where T : class
|
||||
=> service.Include(source, path);
|
||||
|
||||
public static Task<T> FirstOrDefaultAsync<T>(this IQueryable<T> source,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.FirstOrDefaultAsync(source, cancellationToken);
|
||||
|
||||
public static Task<T> FirstOrDefaultAsync<T>(this IQueryable<T> source,
|
||||
Expression<Func<T, bool>> predicate,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.FirstOrDefaultAsync(source, predicate, cancellationToken);
|
||||
|
||||
public static Task<T> FirstAsync<T>(this IQueryable<T> source,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.FirstAsync(source, cancellationToken);
|
||||
|
||||
public static Task<T> FirstAsync<T>(this IQueryable<T> source,
|
||||
Expression<Func<T, bool>> predicate,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.FirstAsync(source, predicate, cancellationToken);
|
||||
|
||||
public static Task<bool> AnyAsync<T>(this IQueryable<T> source,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.AnyAsync(source, cancellationToken);
|
||||
|
||||
public static Task<bool> AnyAsync<T>(this IQueryable<T> source,
|
||||
Expression<Func<T, bool>> predicate,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.AnyAsync(source, predicate, cancellationToken);
|
||||
|
||||
public static Task<List<T>> ToListAsync<T>(this IQueryable<T> source,
|
||||
CancellationToken cancellationToken = default) where T : class =>
|
||||
service.ToListAsync(source, cancellationToken);
|
||||
}
|
||||
}
|
16
PoweredSoft.DbContext.Core/IContextServiceProvider.cs
Normal file
16
PoweredSoft.DbContext.Core/IContextServiceProvider.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbContextServiceProvider
|
||||
{
|
||||
IDbContextService GetServiceForType<TContext>();
|
||||
IDbContextService GetServiceForType(Type contextType);
|
||||
}
|
||||
|
||||
public interface IContextServiceFactory
|
||||
{
|
||||
bool CanService(Type contextType);
|
||||
IDbContextService Create(Type contextType);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
|
||||
public interface IQueryableExtensionService : IQueryableOperationsService
|
||||
{
|
||||
IQueryableService ResolveService<T>(IQueryable<T> queryable);
|
||||
IQueryableService ResolveService(IQueryable queryable);
|
||||
}
|
||||
}
|
20
PoweredSoft.DbContext.Core/IDbContextService.cs
Normal file
20
PoweredSoft.DbContext.Core/IDbContextService.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbContextService
|
||||
{
|
||||
IDbSetService<TEntity> Set<TEntity>() where TEntity : class;
|
||||
IDbSetService Set(Type entityType);
|
||||
int SaveChanges();
|
||||
Task<int> SaveChangesAsync();
|
||||
T GetUnderlyingOrm<T>() where T : class;
|
||||
IEnumerable<PropertyInfo> GetKeyProperties(Type entityType);
|
||||
IEnumerable<Expression<Func<TEntity, object>>> GetKeyProperties<TEntity>();
|
||||
IDbContextTransactionService BeginTransaction();
|
||||
}
|
||||
}
|
10
PoweredSoft.DbContext.Core/IDbContextTransactionService.cs
Normal file
10
PoweredSoft.DbContext.Core/IDbContextTransactionService.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbContextTransactionService : IDisposable
|
||||
{
|
||||
void Commit();
|
||||
void Rollback();
|
||||
}
|
||||
}
|
10
PoweredSoft.DbContext.Core/IDbQueryService.cs
Normal file
10
PoweredSoft.DbContext.Core/IDbQueryService.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbQueryService : IOrderedQueryable
|
||||
{
|
||||
IDbQueryService AsNoTracking();
|
||||
IDbQueryService Include(string path);
|
||||
}
|
||||
}
|
9
PoweredSoft.DbContext.Core/IDbQueryService`.cs
Normal file
9
PoweredSoft.DbContext.Core/IDbQueryService`.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbQueryService<TEntity> : IOrderedQueryable<TEntity>, IDbQueryService
|
||||
where TEntity : class
|
||||
{
|
||||
}
|
||||
}
|
16
PoweredSoft.DbContext.Core/IDbSetService.cs
Normal file
16
PoweredSoft.DbContext.Core/IDbSetService.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbSetService : IDbQueryService
|
||||
{
|
||||
IList Local { get; }
|
||||
|
||||
object Add(object entity);
|
||||
void AddRange(IEnumerable entities);
|
||||
object Remove(object entity);
|
||||
void RemoveRange(IEnumerable entities);
|
||||
object Find(params object[] keyValues);
|
||||
object Attach(object entity);
|
||||
}
|
||||
}
|
17
PoweredSoft.DbContext.Core/IDbSetService`.cs
Normal file
17
PoweredSoft.DbContext.Core/IDbSetService`.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IDbSetService<TEntity> : IDbQueryService<TEntity>, IDbSetService
|
||||
where TEntity : class
|
||||
{
|
||||
new ICollection<TEntity> Local { get; }
|
||||
|
||||
TEntity Add(TEntity entity);
|
||||
TEntity Remove(TEntity entity);
|
||||
void AddRange(IEnumerable<TEntity> entities);
|
||||
void RemoveRange(IEnumerable<TEntity> entities);
|
||||
TEntity Attach(TEntity entity);
|
||||
}
|
||||
}
|
30
PoweredSoft.DbContext.Core/IQueryableOperationsService.cs
Normal file
30
PoweredSoft.DbContext.Core/IQueryableOperationsService.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IQueryableOperationsService
|
||||
{
|
||||
IQueryable<T> Include<T, TProperty>(IQueryable<T> source, Expression<Func<T, TProperty>> path)
|
||||
where T : class;
|
||||
IQueryable<T> AsNoTracking<T>(IQueryable<T> source)
|
||||
where T : class;
|
||||
IQueryable AsNoTracking(IQueryable source);
|
||||
IQueryable<T> Include<T>(IQueryable<T> source, string path)
|
||||
where T : class;
|
||||
Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class;
|
||||
Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate,
|
||||
CancellationToken cancellationToken = default) where T : class;
|
||||
Task<T> FirstAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class;
|
||||
Task<T> FirstAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate,
|
||||
CancellationToken cancellationToken = default) where T : class;
|
||||
Task<List<T>> ToListAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class;
|
||||
|
||||
Task<bool> AnyAsync<T>(IQueryable<T> source, System.Linq.Expressions.Expression<System.Func<T, bool>> predicate, CancellationToken cancellationToken) where T : class;
|
||||
Task<bool> AnyAsync<T>(IQueryable<T> source, CancellationToken cancellationToken) where T : class;
|
||||
}
|
||||
}
|
11
PoweredSoft.DbContext.Core/IQueryableService.cs
Normal file
11
PoweredSoft.DbContext.Core/IQueryableService.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace PoweredSoft.DbContext.Core
|
||||
{
|
||||
public interface IQueryableService : IQueryableOperationsService
|
||||
{
|
||||
bool CanHandle<T>(IQueryable<T> queryable);
|
||||
bool CanHandle(IQueryable queryable);
|
||||
}
|
||||
}
|
18
PoweredSoft.DbContext.Core/PoweredSoft.DbContext.Core.csproj
Normal file
18
PoweredSoft.DbContext.Core/PoweredSoft.DbContext.Core.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Copyright>Powered Softwares Inc.</Copyright>
|
||||
<Version>1.1.0$(VersionSuffix)</Version>
|
||||
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||
<Product>$(MSBuildProjectName)</Product>
|
||||
<Description>initial</Description>
|
||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||
<PackageReleaseNotes>initial</PackageReleaseNotes>
|
||||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
|
||||
<Company>PoweredSoft</Company>
|
||||
<Authors>PoweredSoft</Authors>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
89
PoweredSoft.DbContext.EntityFramework/DbContextService.cs
Normal file
89
PoweredSoft.DbContext.EntityFramework/DbContextService.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Entity.Core.Metadata.Edm;
|
||||
using System.Linq;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class DbContextService : IDbContextService
|
||||
{
|
||||
public DbContextService(System.Data.Entity.DbContext dbContext)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
}
|
||||
|
||||
protected System.Data.Entity.DbContext DbContext { get; }
|
||||
|
||||
public IDbContextTransactionService BeginTransaction()
|
||||
{
|
||||
return new DbContextTransactionService(DbContext.Database.BeginTransaction());
|
||||
}
|
||||
|
||||
public IEnumerable<PropertyInfo> GetKeyProperties(Type entityType)
|
||||
{
|
||||
var metadata = ((IObjectContextAdapter)DbContext).ObjectContext.MetadataWorkspace;
|
||||
|
||||
// Get the mapping between CLR types and metadata OSpace
|
||||
var objectItemCollection = ((ObjectItemCollection)metadata.GetItemCollection(DataSpace.OSpace));
|
||||
|
||||
// Get metadata for given CLR type
|
||||
var entityMetadata = metadata
|
||||
.GetItems<EntityType>(DataSpace.OSpace)
|
||||
.Single(e => objectItemCollection.GetClrType(e) == entityType);
|
||||
|
||||
var ret = entityMetadata.KeyProperties.Select(t => entityType.GetProperty(t.Name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IEnumerable<Expression<Func<TEntity, object>>> GetKeyProperties<TEntity>()
|
||||
{
|
||||
var keyProps = GetKeyProperties(typeof(TEntity));
|
||||
|
||||
var parameter = Expression.Parameter(typeof(TEntity));
|
||||
var result = keyProps
|
||||
.Select(keyProp =>
|
||||
{
|
||||
var property = Expression.Property(parameter, keyProp);
|
||||
var lambda = Expression.Lambda<Func<TEntity, object>>(Expression.Convert(property, typeof(Object)), parameter);
|
||||
return (Expression<Func<TEntity, object>>)lambda;
|
||||
})
|
||||
.ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
public T GetUnderlyingOrm<T>() where T : class
|
||||
{
|
||||
return this.DbContext as T;
|
||||
}
|
||||
|
||||
public int SaveChanges()
|
||||
{
|
||||
return DbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public Task<int> SaveChangesAsync()
|
||||
{
|
||||
return DbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public IDbSetService<TEntity> Set<TEntity>() where TEntity : class
|
||||
{
|
||||
var realDbSet = DbContext.Set<TEntity>();
|
||||
var dbSet = new DbSetService<TEntity>(realDbSet);
|
||||
return dbSet;
|
||||
}
|
||||
|
||||
public IDbSetService Set(Type entityType)
|
||||
{
|
||||
var realDbSet = DbContext.Set(entityType);
|
||||
var dbSet = new DbSetService(realDbSet);
|
||||
return dbSet;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class DbContextTransactionService : IDbContextTransactionService
|
||||
{
|
||||
private readonly System.Data.Entity.DbContextTransaction dbContextTransaction;
|
||||
|
||||
public DbContextTransactionService(System.Data.Entity.DbContextTransaction dbContextTransaction)
|
||||
{
|
||||
this.dbContextTransaction = dbContextTransaction;
|
||||
}
|
||||
|
||||
public void Commit() => dbContextTransaction.Commit();
|
||||
|
||||
public void Dispose() => dbContextTransaction.Dispose();
|
||||
|
||||
public void Rollback() => dbContextTransaction.Rollback();
|
||||
}
|
||||
}
|
43
PoweredSoft.DbContext.EntityFramework/DbQueryService.cs
Normal file
43
PoweredSoft.DbContext.EntityFramework/DbQueryService.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class DbQueryService : IDbQueryService
|
||||
{
|
||||
public DbQueryService(DbQuery dbQuery)
|
||||
{
|
||||
DbQuery = dbQuery;
|
||||
}
|
||||
|
||||
public Expression Expression => ((IQueryable)DbQuery).Expression;
|
||||
|
||||
public Type ElementType => ((IQueryable)DbQuery).ElementType;
|
||||
|
||||
public IQueryProvider Provider => ((IQueryable)DbQuery).Provider;
|
||||
|
||||
protected DbQuery DbQuery { get; }
|
||||
|
||||
public IDbQueryService AsNoTracking()
|
||||
{
|
||||
var efQuery = DbQuery.AsNoTracking();
|
||||
var ret = new DbQueryService(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator() => ((IQueryable)DbQuery).GetEnumerator();
|
||||
|
||||
public IDbQueryService Include(string path)
|
||||
{
|
||||
var efQuery = DbQuery.Include(path);
|
||||
var ret = new DbQueryService(efQuery);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
60
PoweredSoft.DbContext.EntityFramework/DbQueryService`.cs
Normal file
60
PoweredSoft.DbContext.EntityFramework/DbQueryService`.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class DbQueryService<TEntity> : IDbQueryService<TEntity>
|
||||
where TEntity : class
|
||||
{
|
||||
public DbQueryService(DbQuery<TEntity> dbQuery)
|
||||
{
|
||||
DbQuery = dbQuery;
|
||||
}
|
||||
|
||||
public Expression Expression => ((IQueryable<TEntity>)DbQuery).Expression;
|
||||
|
||||
public Type ElementType => ((IQueryable<TEntity>)DbQuery).ElementType;
|
||||
|
||||
public IQueryProvider Provider => ((IQueryable<TEntity>)DbQuery).Provider;
|
||||
|
||||
protected DbQuery<TEntity> DbQuery { get; }
|
||||
|
||||
public IDbQueryService<TEntity> AsNoTracking()
|
||||
{
|
||||
var efQuery = DbQuery.AsNoTracking();
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator() => ((IQueryable<TEntity>)DbQuery).GetEnumerator();
|
||||
|
||||
public IDbQueryService<TEntity> Include(string path)
|
||||
{
|
||||
var efQuery = DbQuery.Include(path);
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IDbQueryService IDbQueryService.AsNoTracking()
|
||||
{
|
||||
var efQuery = DbQuery.AsNoTracking();
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IEnumerator<TEntity> IEnumerable<TEntity>.GetEnumerator() => ((IQueryable<TEntity>)DbQuery).GetEnumerator();
|
||||
|
||||
IDbQueryService IDbQueryService.Include(string path)
|
||||
{
|
||||
var efQuery = DbQuery.Include(path);
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
31
PoweredSoft.DbContext.EntityFramework/DbSetService.cs
Normal file
31
PoweredSoft.DbContext.EntityFramework/DbSetService.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class DbSetService : DbQueryService, IDbSetService
|
||||
{
|
||||
protected DbSet DbSet { get; }
|
||||
|
||||
public DbSetService(DbSet dbSet) : base(dbSet)
|
||||
{
|
||||
DbSet = dbSet;
|
||||
}
|
||||
|
||||
public IList Local => DbSet.Local;
|
||||
|
||||
public object Add(object entity) => DbSet.Add(entity);
|
||||
|
||||
public object Remove(object entity) => DbSet.Remove(entity);
|
||||
public void AddRange(IEnumerable entities) => DbSet.AddRange(entities);
|
||||
public void RemoveRange(IEnumerable entities) => DbSet.RemoveRange(entities);
|
||||
|
||||
public object Find(params object[] keyValues) => DbSet.Find(keyValues);
|
||||
|
||||
public object Attach(object entity) => DbSet.Attach(entity);
|
||||
}
|
||||
}
|
56
PoweredSoft.DbContext.EntityFramework/DbSetService`.cs
Normal file
56
PoweredSoft.DbContext.EntityFramework/DbSetService`.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class DbSetService<TEntity> : DbQueryService<TEntity>, IDbSetService<TEntity>
|
||||
where TEntity : class
|
||||
{
|
||||
public DbSetService(DbSet<TEntity> dbSet) : base(dbSet)
|
||||
{
|
||||
DbSet = dbSet;
|
||||
}
|
||||
|
||||
protected DbSet<TEntity> DbSet { get; }
|
||||
|
||||
public ICollection<TEntity> Local => DbSet.Local;
|
||||
|
||||
IList IDbSetService.Local => DbSet.Local;
|
||||
|
||||
public TEntity Add(TEntity entity) => DbSet.Add(entity);
|
||||
|
||||
public TEntity Remove(TEntity entity) => DbSet.Remove(entity);
|
||||
|
||||
IEnumerator<TEntity> IEnumerable<TEntity>.GetEnumerator() => ((IQueryable<TEntity>)DbSet).GetEnumerator();
|
||||
|
||||
public TEntity Create() => DbSet.Create();
|
||||
|
||||
public TEntity Attach(TEntity entity) => DbSet.Attach(entity);
|
||||
|
||||
public DbSet<TEntity> GetEntityFrameworkSet() => DbSet;
|
||||
|
||||
public TEntity Find(params object[] keyValues) => DbSet.Find(keyValues);
|
||||
|
||||
void IDbSetService<TEntity>.AddRange(IEnumerable<TEntity> entities) => DbSet.AddRange(entities);
|
||||
|
||||
void IDbSetService<TEntity>.RemoveRange(IEnumerable<TEntity> entities) => DbSet.RemoveRange(entities);
|
||||
|
||||
public object Add(object entity) => DbSet.Add((TEntity)entity);
|
||||
|
||||
public void AddRange(IEnumerable entities) => DbSet.AddRange(entities.Cast<TEntity>());
|
||||
|
||||
public object Remove(object entity) => DbSet.Remove((TEntity)entity);
|
||||
|
||||
public void RemoveRange(IEnumerable entities) => DbSet.RemoveRange(entities.Cast<TEntity>());
|
||||
|
||||
object IDbSetService.Find(params object[] keyValues) => DbSet.Find(keyValues);
|
||||
|
||||
public object Attach(object entity) => DbSet.Attach((TEntity)entity);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class EntityFrameworkDbContextServiceFactory : IContextServiceFactory
|
||||
{
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
public EntityFrameworkDbContextServiceFactory(IServiceProvider serviceProvider)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public bool CanService(Type contextType)
|
||||
{
|
||||
return typeof(System.Data.Entity.DbContext).IsAssignableFrom(contextType);
|
||||
}
|
||||
|
||||
public IDbContextService Create(Type contextType)
|
||||
{
|
||||
var service = serviceProvider.GetService(contextType) as System.Data.Entity.DbContext;
|
||||
var contextService = new DbContextService(service);
|
||||
return contextService;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public class EntityFrameworkQueryableService : IQueryableService
|
||||
{
|
||||
public Task<bool> AnyAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.AnyAsync(source, predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<bool> AnyAsync<T>(IQueryable<T> source, CancellationToken cancellationToken) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.AnyAsync(source, cancellationToken);
|
||||
}
|
||||
|
||||
public IQueryable<T> AsNoTracking<T>(IQueryable<T> source) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.AsNoTracking(source);
|
||||
}
|
||||
|
||||
public IQueryable AsNoTracking(IQueryable source)
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.AsNoTracking(source);
|
||||
}
|
||||
|
||||
public bool CanHandle<T>(IQueryable<T> queryable)
|
||||
{
|
||||
return queryable.Provider is System.Data.Entity.Infrastructure.IDbAsyncQueryProvider;
|
||||
}
|
||||
|
||||
public bool CanHandle(IQueryable queryable)
|
||||
{
|
||||
return queryable.Provider is System.Data.Entity.Infrastructure.IDbAsyncQueryProvider;
|
||||
}
|
||||
|
||||
public Task<T> FirstAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.FirstAsync(source, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<T> FirstAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.FirstAsync(source, predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(source, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(source, predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public IQueryable<T> Include<T, TProperty>(IQueryable<T> source, Expression<Func<T, TProperty>> path)
|
||||
where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.Include(source, path);
|
||||
}
|
||||
|
||||
public IQueryable<T> Include<T>(IQueryable<T> source, string path)
|
||||
where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.Include(source, path);
|
||||
}
|
||||
|
||||
public Task<List<T>> ToListAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return System.Data.Entity.QueryableExtensions.ToListAsync(source, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.1;net461</TargetFrameworks>
|
||||
<Copyright>Powered Softwares Inc.</Copyright>
|
||||
<Version>1.1.0$(VersionSuffix)</Version>
|
||||
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||
<Product>$(MSBuildProjectName)</Product>
|
||||
<Description>initial</Description>
|
||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||
<PackageReleaseNotes>initial</PackageReleaseNotes>
|
||||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
|
||||
<Company>PoweredSoft</Company>
|
||||
<Authors>PoweredSoft</Authors>
|
||||
<Deterministic>False</Deterministic>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EntityFramework" Version="6.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PoweredSoft.DbContext.Core\PoweredSoft.DbContext.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,18 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFramework
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddPoweredSoftEntityFrameworkDbContextServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IQueryableService, EntityFrameworkQueryableService>();
|
||||
services.AddSingleton<IContextServiceFactory, EntityFrameworkDbContextServiceFactory>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using PoweredSoft.Reflection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public class DbContextService : IDbContextService
|
||||
{
|
||||
public DbContextService(Microsoft.EntityFrameworkCore.DbContext dbContext)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
}
|
||||
|
||||
protected Microsoft.EntityFrameworkCore.DbContext DbContext { get; }
|
||||
|
||||
private MethodInfo setGenericMethodInfo = null;
|
||||
|
||||
public IDbContextTransactionService BeginTransaction()
|
||||
{
|
||||
return new DbContextTransactionService(DbContext.Database.BeginTransaction());
|
||||
}
|
||||
|
||||
public IEnumerable<PropertyInfo> GetKeyProperties(Type entityType)
|
||||
{
|
||||
var key = DbContext.Model.GetEntityTypes().First(t => t.ClrType == entityType).FindPrimaryKey();
|
||||
var keysProperties = key.Properties.Select(t => t.PropertyInfo);
|
||||
return keysProperties;
|
||||
}
|
||||
|
||||
public IEnumerable<Expression<Func<TEntity, object>>> GetKeyProperties<TEntity>()
|
||||
{
|
||||
var keyProps = GetKeyProperties(typeof(TEntity));
|
||||
|
||||
var parameter = Expression.Parameter(typeof(TEntity));
|
||||
var result = keyProps
|
||||
.Select(keyProp =>
|
||||
{
|
||||
var property = Expression.Property(parameter, keyProp);
|
||||
var lambda = Expression.Lambda<Func<TEntity, object>>(Expression.Convert(property, typeof(Object)), parameter);
|
||||
return (Expression<Func<TEntity, object>>)lambda;
|
||||
})
|
||||
.ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
public T GetUnderlyingOrm<T>() where T : class
|
||||
{
|
||||
return this.DbContext as T;
|
||||
}
|
||||
|
||||
public int SaveChanges()
|
||||
{
|
||||
return DbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public Task<int> SaveChangesAsync()
|
||||
{
|
||||
return DbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
[MethodKey("SetGeneric")]
|
||||
public IDbSetService<TEntity> Set<TEntity>() where TEntity : class
|
||||
{
|
||||
var realDbSet = DbContext.Set<TEntity>();
|
||||
var dbSet = new DbSetService<TEntity>(realDbSet);
|
||||
return dbSet;
|
||||
}
|
||||
|
||||
public IDbSetService Set(Type entityType)
|
||||
{
|
||||
if (setGenericMethodInfo == null)
|
||||
setGenericMethodInfo = this.GetType().GetMethodByKey("SetGeneric", BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
var method = setGenericMethodInfo.MakeGenericMethod(entityType);
|
||||
var result = method.Invoke(this, new object[] { }) as IDbSetService;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public class DbContextTransactionService : IDbContextTransactionService
|
||||
{
|
||||
private readonly IDbContextTransaction dbContextTransaction;
|
||||
|
||||
public DbContextTransactionService(IDbContextTransaction dbContextTransaction)
|
||||
{
|
||||
this.dbContextTransaction = dbContextTransaction;
|
||||
}
|
||||
|
||||
public void Commit() => dbContextTransaction.Commit();
|
||||
|
||||
public void Dispose() => dbContextTransaction.Dispose();
|
||||
|
||||
public void Rollback() => dbContextTransaction.Rollback();
|
||||
}
|
||||
}
|
61
PoweredSoft.DbContext.EntityFrameworkCore/DbQueryService`.cs
Normal file
61
PoweredSoft.DbContext.EntityFrameworkCore/DbQueryService`.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public class DbQueryService<TEntity> : IDbQueryService<TEntity>
|
||||
where TEntity : class
|
||||
{
|
||||
|
||||
public DbQueryService(IQueryable<TEntity> queryable)
|
||||
{
|
||||
Queryable = queryable;
|
||||
}
|
||||
|
||||
public Expression Expression => ((IQueryable<TEntity>)Queryable).Expression;
|
||||
|
||||
public Type ElementType => ((IQueryable<TEntity>)Queryable).ElementType;
|
||||
|
||||
public IQueryProvider Provider => ((IQueryable<TEntity>)Queryable).Provider;
|
||||
|
||||
public IQueryable<TEntity> Queryable { get; }
|
||||
|
||||
public IDbQueryService<TEntity> AsNoTracking()
|
||||
{
|
||||
var efQuery = Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AsNoTracking(Queryable);
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator() => ((IQueryable<TEntity>)Queryable).GetEnumerator();
|
||||
|
||||
public IDbQueryService<TEntity> Include(string path)
|
||||
{
|
||||
var efQuery = Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Include(Queryable, path);
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IDbQueryService IDbQueryService.AsNoTracking()
|
||||
{
|
||||
var efQuery = Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AsNoTracking(Queryable);
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
IEnumerator<TEntity> IEnumerable<TEntity>.GetEnumerator() => ((IQueryable<TEntity>)Queryable).GetEnumerator();
|
||||
|
||||
IDbQueryService IDbQueryService.Include(string path)
|
||||
{
|
||||
var efQuery = Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Include(Queryable, path);
|
||||
var ret = new DbQueryService<TEntity>(efQuery);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
55
PoweredSoft.DbContext.EntityFrameworkCore/DbSetService`.cs
Normal file
55
PoweredSoft.DbContext.EntityFrameworkCore/DbSetService`.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public class DbSetService<TEntity> : DbQueryService<TEntity>, IDbSetService<TEntity>
|
||||
where TEntity : class
|
||||
{
|
||||
public DbSetService(DbSet<TEntity> dbSet) : base(dbSet)
|
||||
{
|
||||
DbSet = dbSet;
|
||||
}
|
||||
|
||||
protected DbSet<TEntity> DbSet { get; }
|
||||
|
||||
public ICollection<TEntity> Local => DbSet.Local;
|
||||
|
||||
IList IDbSetService.Local => DbSet.Local.ToList();
|
||||
|
||||
public TEntity Add(TEntity entity) => DbSet.Add(entity).Entity;
|
||||
|
||||
public TEntity Remove(TEntity entity) => DbSet.Remove(entity).Entity;
|
||||
|
||||
IEnumerator<TEntity> IEnumerable<TEntity>.GetEnumerator() => ((IQueryable<TEntity>)DbSet).GetEnumerator();
|
||||
|
||||
|
||||
public TEntity Attach(TEntity entity) => DbSet.Attach(entity).Entity;
|
||||
|
||||
public void AddRange(IEnumerable<TEntity> entities) => DbSet.AddRange(entities);
|
||||
|
||||
public void RemoveRange(IEnumerable<TEntity> entities) => DbSet.RemoveRange(entities);
|
||||
|
||||
public DbSet<TEntity> GetEntityFrameworkSet() => DbSet;
|
||||
|
||||
public TEntity Find(params object[] keyValues) => DbSet.Find(keyValues);
|
||||
|
||||
public object Add(object entity) => DbSet.Add((TEntity)entity);
|
||||
|
||||
public void AddRange(IEnumerable entities) => DbSet.AddRange(entities.Cast<TEntity>());
|
||||
|
||||
public object Remove(object entity) => DbSet.Remove((TEntity)entity);
|
||||
|
||||
public void RemoveRange(IEnumerable entities) => DbSet.RemoveRange(entities.Cast<TEntity>());
|
||||
|
||||
object IDbSetService.Find(params object[] keyValues) => DbSet.Find(keyValues);
|
||||
|
||||
public object Attach(object entity) => DbSet.Attach((TEntity)entity).Entity;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public class EntityFrameworkCoreDbContextServiceFactory : IContextServiceFactory
|
||||
{
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
public EntityFrameworkCoreDbContextServiceFactory(IServiceProvider serviceProvider)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public bool CanService(Type contextType)
|
||||
{
|
||||
return typeof(Microsoft.EntityFrameworkCore.DbContext).IsAssignableFrom(contextType);
|
||||
}
|
||||
|
||||
public IDbContextService Create(Type contextType)
|
||||
{
|
||||
var service = serviceProvider.GetService(contextType) as Microsoft.EntityFrameworkCore.DbContext;
|
||||
var contextService = new DbContextService(service);
|
||||
return contextService;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
using Microsoft.EntityFrameworkCore.Query.Internal;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using PoweredSoft.Reflection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public class EntityFrameworkCoreQueryableService : IQueryableService
|
||||
{
|
||||
private MethodInfo asNoTrackingGeneric = null;
|
||||
|
||||
public Task<bool> AnyAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AnyAsync(source, predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<bool> AnyAsync<T>(IQueryable<T> source, CancellationToken cancellationToken) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AnyAsync(source, cancellationToken);
|
||||
}
|
||||
|
||||
[MethodKey("AsNoTrackingGeneric")]
|
||||
public IQueryable<T> AsNoTracking<T>(IQueryable<T> source) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.AsNoTracking(source);
|
||||
}
|
||||
|
||||
public IQueryable AsNoTracking(IQueryable source)
|
||||
{
|
||||
if (asNoTrackingGeneric == null)
|
||||
asNoTrackingGeneric = this.GetType().GetMethodByKey("AsNoTrackingGeneric");
|
||||
|
||||
var elementType = source.ElementType;
|
||||
var method = asNoTrackingGeneric.MakeGenericMethod(elementType);
|
||||
var result = method.Invoke(this, new object[] { source });
|
||||
return result as IQueryable;
|
||||
}
|
||||
|
||||
public bool CanHandle<T>(IQueryable<T> queryable)
|
||||
{
|
||||
return queryable.Provider is IAsyncQueryProvider;
|
||||
}
|
||||
|
||||
public bool CanHandle(IQueryable queryable)
|
||||
{
|
||||
return queryable.Provider is IAsyncQueryProvider;
|
||||
}
|
||||
|
||||
public Task<T> FirstAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstAsync(source, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<T> FirstAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstAsync(source, predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(source, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(source, predicate, cancellationToken);
|
||||
}
|
||||
|
||||
public IQueryable<T> Include<T, TProperty>(IQueryable<T> source, Expression<Func<T, TProperty>> path)
|
||||
where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Include(source, path);
|
||||
}
|
||||
|
||||
public IQueryable<T> Include<T>(IQueryable<T> source, string path)
|
||||
where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Include(source, path);
|
||||
}
|
||||
|
||||
public Task<List<T>> ToListAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
{
|
||||
return Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync(source, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Copyright>Powered Softwares Inc.</Copyright>
|
||||
<Version>1.1.0$(VersionSuffix)</Version>
|
||||
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||
<Product>$(MSBuildProjectName)</Product>
|
||||
<Description>initial</Description>
|
||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||
<PackageReleaseNotes>initial</PackageReleaseNotes>
|
||||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
|
||||
<Company>PoweredSoft</Company>
|
||||
<Authors>PoweredSoft</Authors>
|
||||
<Deterministic>False</Deterministic>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PoweredSoft.DbContext.Core\PoweredSoft.DbContext.Core.csproj" />
|
||||
<ProjectReference Include="..\PoweredSoft.Reflection\PoweredSoft.Reflection.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,18 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext.EntityFrameworkCore
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddPoweredSoftEntityFrameworkCoreDbContextServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IQueryableService, EntityFrameworkCoreQueryableService>();
|
||||
services.AddSingleton<IContextServiceFactory, EntityFrameworkCoreDbContextServiceFactory>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
32
PoweredSoft.DbContext/DbContextServiceProvider.cs
Normal file
32
PoweredSoft.DbContext/DbContextServiceProvider.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext
|
||||
{
|
||||
public class DbContextServiceProvider : IDbContextServiceProvider
|
||||
{
|
||||
private readonly IEnumerable<IContextServiceFactory> factories;
|
||||
|
||||
public DbContextServiceProvider(IEnumerable<IContextServiceFactory> factories)
|
||||
{
|
||||
this.factories = factories;
|
||||
}
|
||||
|
||||
public IDbContextService GetServiceForType<TContext>()
|
||||
{
|
||||
return GetServiceForType(typeof(TContext));
|
||||
}
|
||||
|
||||
public IDbContextService GetServiceForType(Type contextType)
|
||||
{
|
||||
var factory = factories.FirstOrDefault(t => t.CanService(contextType));
|
||||
if (factory == null)
|
||||
throw new NotSupportedException($"Could not resolve which factory should create a context service for {contextType}");
|
||||
|
||||
return factory.Create(contextType);
|
||||
}
|
||||
}
|
||||
}
|
26
PoweredSoft.DbContext/PoweredSoft.DbContext.csproj
Normal file
26
PoweredSoft.DbContext/PoweredSoft.DbContext.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Copyright>Powered Softwares Inc.</Copyright>
|
||||
<Version>1.1.0$(VersionSuffix)</Version>
|
||||
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||
<Product>$(MSBuildProjectName)</Product>
|
||||
<Description>initial</Description>
|
||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||
<PackageReleaseNotes>initial</PackageReleaseNotes>
|
||||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
|
||||
<Company>PoweredSoft</Company>
|
||||
<Authors>PoweredSoft</Authors>
|
||||
<Deterministic>False</Deterministic>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PoweredSoft.DbContext.Core\PoweredSoft.DbContext.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
73
PoweredSoft.DbContext/QueryableExtensionService.cs
Normal file
73
PoweredSoft.DbContext/QueryableExtensionService.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.DbContext
|
||||
{
|
||||
public class QueryableExtensionService : IQueryableExtensionService
|
||||
{
|
||||
private readonly IEnumerable<IQueryableService> services;
|
||||
|
||||
public QueryableExtensionService(IEnumerable<IQueryableService> services)
|
||||
{
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public IQueryableService ResolveService<T>(IQueryable<T> queryable)
|
||||
{
|
||||
var service = this.services.FirstOrDefault(t => t.CanHandle(queryable));
|
||||
if (service == null)
|
||||
throw new Exception($"Could not resolve any service to execute operation..");
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
public IQueryableService ResolveService(IQueryable queryable)
|
||||
{
|
||||
var service = this.services.FirstOrDefault(t => t.CanHandle(queryable));
|
||||
if (service == null)
|
||||
throw new Exception($"Could not resolve any service to execute operation..");
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
public IQueryable<T> AsNoTracking<T>(IQueryable<T> source) where T : class
|
||||
=> ResolveService(source).AsNoTracking(source);
|
||||
|
||||
public IQueryable AsNoTracking(IQueryable source)
|
||||
=> ResolveService(source).AsNoTracking(source);
|
||||
|
||||
public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).FirstOrDefaultAsync(source, cancellationToken: cancellationToken);
|
||||
|
||||
public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).FirstOrDefaultAsync(source, predicate, cancellationToken: cancellationToken);
|
||||
|
||||
public Task<T> FirstAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).FirstAsync(source, cancellationToken: cancellationToken);
|
||||
public Task<T> FirstAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).FirstAsync(source, predicate, cancellationToken: cancellationToken);
|
||||
|
||||
public Task<bool> AnyAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).AnyAsync(source, cancellationToken: cancellationToken);
|
||||
|
||||
public Task<bool> AnyAsync<T>(IQueryable<T> source, Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).AnyAsync(source, predicate, cancellationToken: cancellationToken);
|
||||
|
||||
public IQueryable<T> Include<T, TProperty>(IQueryable<T> source, Expression<Func<T, TProperty>> path)
|
||||
where T : class
|
||||
=> ResolveService(source).Include(source, path);
|
||||
|
||||
public IQueryable<T> Include<T>(IQueryable<T> source, string path)
|
||||
where T : class
|
||||
=> ResolveService(source).Include(source, path);
|
||||
|
||||
public Task<List<T>> ToListAsync<T>(IQueryable<T> source, CancellationToken cancellationToken = default) where T : class
|
||||
=> ResolveService(source).ToListAsync(source, cancellationToken: cancellationToken);
|
||||
|
||||
}
|
||||
}
|
25
PoweredSoft.DbContext/ServiceCollectionExtensions.cs
Normal file
25
PoweredSoft.DbContext/ServiceCollectionExtensions.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using PoweredSoft.DbContext.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.DbContext
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddPoweredSoftDbContextServices(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddSingleton<IQueryableExtensionService, QueryableExtensionService>();
|
||||
services.TryAddSingleton<IDbContextServiceProvider, DbContextServiceProvider>();
|
||||
return services;
|
||||
}
|
||||
|
||||
public static void InitPoweredSoftDbContextExtensions(this IServiceProvider serviceProvider)
|
||||
{
|
||||
var queryableExtensionService = serviceProvider.GetRequiredService<IQueryableExtensionService>();
|
||||
DbContextQueryableExtensions.InitializeExtensionService(queryableExtensionService);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user