This commit is contained in:
xuejiaming 2022-12-23 15:15:55 +08:00
parent cd002c8484
commit 7bc9751e0a
15 changed files with 74 additions and 78 deletions

View File

@ -55,7 +55,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.ShardingConsole", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.OracleIssue", "samples\Sample.OracleIssue\Sample.OracleIssue.csproj", "{BF4FEA2A-3F09-47D8-9BF7-4261D8D1671D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShardingCore.Test6x", "test\ShardingCore.Test6x\ShardingCore.Test6x.csproj", "{8ED3A191-5A29-4599-B383-9FD225CC0BA2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShardingCore.Test6x", "test\ShardingCore.Test6x\ShardingCore.Test6x.csproj", "{8ED3A191-5A29-4599-B383-9FD225CC0BA2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src6", "src6", "{585A790B-8B19-430F-BEB7-9F7D1A3AAFAA}"
EndProject

View File

@ -1,10 +1,10 @@
:start
::定义版本
set EFCORE7=7.7.0.9
set EFCORE6=7.6.0.9
set EFCORE5=7.5.0.9
set EFCORE3=7.3.0.9
set EFCORE2=7.2.0.9
set EFCORE7=7.7.1.1-preview1
set EFCORE6=7.6.1.1-preview1
set EFCORE5=7.5.1.1-preview1
set EFCORE3=7.3.1.1-preview1
set EFCORE2=7.2.1.1-preview1
::删除所有bin与obj下的文件
@echo off

View File

@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using ShardingCore.Exceptions;
using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
@ -35,34 +36,26 @@ namespace ShardingCore.EFCores
public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType());
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.GetOrCreateEntry(entity,entityType);
return stateManager.GetOrCreateEntry(entity, findEntityType);
}
public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer,
ISet<IForeignKey> handledForeignKeys)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer, handledForeignKeys);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, throwOnNonUniqueness);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, entityType);
throw new ShardingCoreNotImplementedException();
}
public override int SaveChanges(bool acceptAllChangesOnSuccess)

View File

@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using ShardingCore.Exceptions;
using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
@ -35,33 +36,25 @@ namespace ShardingCore.EFCores
public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType());
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.GetOrCreateEntry(entity,entityType);
return stateManager.GetOrCreateEntry(entity, findEntityType);
}
public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, throwOnNonUniqueness);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch);
throw new ShardingCoreNotImplementedException();
}
public override int SaveChanges(bool acceptAllChangesOnSuccess)

View File

@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using ShardingCore.Exceptions;
using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
@ -35,33 +36,25 @@ namespace ShardingCore.EFCores
public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType());
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.GetOrCreateEntry(entity,entityType);
return stateManager.GetOrCreateEntry(entity, findEntityType);
}
public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, throwOnNonUniqueness);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch);
throw new ShardingCoreNotImplementedException();
}
public override int SaveChanges(bool acceptAllChangesOnSuccess)

View File

@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using ShardingCore.Exceptions;
using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
@ -35,33 +36,25 @@ namespace ShardingCore.EFCores
public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType());
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.GetOrCreateEntry(entity,entityType);
return stateManager.GetOrCreateEntry(entity, findEntityType);
}
public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, throwOnNonUniqueness);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch);
throw new ShardingCoreNotImplementedException();
}
public override int SaveChanges(bool acceptAllChangesOnSuccess)

View File

@ -1,5 +1,6 @@
#if EFCORE7
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@ -9,6 +10,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using ShardingCore.Exceptions;
using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
@ -33,33 +35,25 @@ namespace ShardingCore.EFCores
public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType());
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.GetOrCreateEntry(entity,entityType);
return stateManager.GetOrCreateEntry(entity, findEntityType);
}
public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, throwOnNonUniqueness);
throw new ShardingCoreNotImplementedException();
}
public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true)
{
var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity);
var dbContextDependencies = genericDbContext.GetService<IDbContextDependencies>();
var stateManager = dbContextDependencies.StateManager;
return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch);
throw new ShardingCoreNotImplementedException();
}
public override int SaveChanges(bool acceptAllChangesOnSuccess)

View File

@ -15,8 +15,11 @@ namespace ShardingCore.Exceptions
*/
[ExcludeFromCodeCoverage]
public class ShardingCoreException : Exception
{
public ShardingCoreException()
{
}
public ShardingCoreException(string message) : base(message)
{
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShardingCore.Exceptions
{
[ExcludeFromCodeCoverage]
public class ShardingCoreNotImplementedException:ShardingCoreException
{
public ShardingCoreNotImplementedException()
{
}
public ShardingCoreNotImplementedException(string message) : base(message)
{
}
public ShardingCoreNotImplementedException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>7.7.0.11</Version>
<Version>$(EFCORE7)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE7;</DefineConstants>
<LangVersion>latest</LangVersion>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.2.0.11</Version>
<Version>$(EFCORE2)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE2;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.3.0.11</Version>
<Version>$(EFCORE3)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE3;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>7.5.0.11</Version>
<Version>$(EFCORE5)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE5;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>7.6.0.11</Version>
<Version>$(EFCORE6)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE6;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />