移除不能用的代码链接

This commit is contained in:
xuejiaming 2022-04-01 10:01:39 +08:00
parent 3689f89451
commit ede5c34286
5 changed files with 29 additions and 16 deletions

View File

@ -17,6 +17,9 @@ using ShardingCore.Core.VirtualDatabase.VirtualTables;
using ShardingCore.Core.VirtualRoutes.TableRoutes;
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
using ShardingCore.Extensions.ShardingQueryableExtensions;
using ShardingCore.Sharding.Abstractions;
using Microsoft.EntityFrameworkCore.Query.Internal;
using ShardingCore.EFCores;
namespace Sample.SqlServer.Controllers
{
@ -88,6 +91,7 @@ namespace Sample.SqlServer.Controllers
// };
//var listAsync = await sql.ToListAsync();
//var resultx112331tt = await _defaultTableDbContext.Set<SysTest>().AsNoTracking().CountAsync();
var resultx112331tt2 = await _defaultTableDbContext.Set<SysTest>().FirstOrDefaultAsync(o => o.Id == "2");
var resultx112331ttaa2 = await _defaultTableDbContext.Set<SysTest>().FirstOrDefaultAsync(o => o.Id == "2");
resultx112331ttaa2.UserId = "zzzz";
@ -151,6 +155,8 @@ namespace Sample.SqlServer.Controllers
var hashSet = unionUserIds.Select(o => o.UserId).ToHashSet();
var hashSetCount = hashSet.Count;
return Ok();
}
@ -162,6 +168,12 @@ namespace Sample.SqlServer.Controllers
public async Task<IActionResult> Get1([FromQuery] int p, [FromQuery] int s)
{
//var queryable= _defaultTableDbContext.Set<SysUserMod>().AsNoSequence().Where(o => true);
// var provider = queryable.Provider as EntityQueryProvider;
// var compiler = provider.GetFieldValue("_queryCompiler") as ShardingQueryCompiler;
// var shardingDbContext = compiler.GetFieldValue("_shardingDbContext") as IShardingDbContext;
Stopwatch sp = new Stopwatch();
sp.Start();
var shardingPageResultAsync = await _defaultTableDbContext.Set<SysUserMod>()

View File

@ -49,8 +49,7 @@ namespace Sample.SqlServer
});
op.ReplaceTableEnsureManager(sp => new SqlServerTableEnsureManager<DefaultShardingDbContext>());
op.AddDefaultDataSource("A",
// "Data Source=localhost;Initial Catalog=ShardingCoreDBXA;Integrated Security=True;"
"Data Source = 101.37.117.55;persist security info=True;Initial Catalog=ShardingCoreDBXA;uid=sa;pwd=xjmumixl7610#;Max Pool Size=100;"
"Data Source=localhost;Initial Catalog=ShardingCoreDBXA;Integrated Security=True;"
);
}).EnsureConfig();
//services.AddShardingDbContext<DefaultShardingDbContext1>(

View File

@ -20,6 +20,7 @@ using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
namespace Samples.AbpSharding
{
public abstract class AbstractShardingAbpDbContext<TDbContext> : AbpDbContext<TDbContext>, IShardingDbContext, ISupportShardingTransaction, ISupportShardingReadWrite
where TDbContext : DbContext
{
@ -570,5 +571,6 @@ namespace Samples.AbpSharding
{
return _shardingDbContextExecutor.GetVirtualDataSource();
}
}
}

View File

@ -27,7 +27,7 @@ namespace ShardingCore.EFCores
public ShardingModelSource(ModelSourceDependencies dependencies) : base(dependencies)
{
Check.NotNull(dependencies, nameof(dependencies));
Console.WriteLine($"ShardingModelSource:{Guid.NewGuid()}");
Dependencies = dependencies;
}

View File

@ -12,19 +12,19 @@ using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
{
public class ShardingChangeTracker: ChangeTracker
{
private readonly ICurrentDbContextDiscover _contextDiscover;
//public class ShardingChangeTracker: ChangeTracker
//{
// private readonly ICurrentDbContextDiscover _contextDiscover;
public ShardingChangeTracker(DbContext context, IStateManager stateManager, IChangeDetector changeDetector, IModel model, IEntityEntryGraphIterator graphIterator) : base(context, stateManager, changeDetector, model, graphIterator)
{
_contextDiscover = context as ICurrentDbContextDiscover?? throw new ShardingCoreNotSupportException($"{context.GetType()} not impl {nameof(ICurrentDbContextDiscover)}");
}
// public ShardingChangeTracker(DbContext context, IStateManager stateManager, IChangeDetector changeDetector, IModel model, IEntityEntryGraphIterator graphIterator) : base(context, stateManager, changeDetector, model, graphIterator)
// {
// _contextDiscover = context as ICurrentDbContextDiscover?? throw new ShardingCoreNotSupportException($"{context.GetType()} not impl {nameof(ICurrentDbContextDiscover)}");
// }
public override bool HasChanges()
{
return _contextDiscover.GetCurrentDbContexts().Any(o =>
o.Value.GetCurrentContexts().Any(r => r.Value.ChangeTracker.HasChanges()));
}
}
// public override bool HasChanges()
// {
// return _contextDiscover.GetCurrentDbContexts().Any(o =>
// o.Value.GetCurrentContexts().Any(r => r.Value.ChangeTracker.HasChanges()));
// }
//}
}