调整项目架构
This commit is contained in:
parent
7cd4ceb736
commit
27c97a0e51
|
@ -1,7 +1,6 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Sample.MySql.Domain.Maps;
|
using Sample.MySql.Domain.Maps;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
|
|
||||||
namespace Sample.MySql.DbContexts
|
namespace Sample.MySql.DbContexts
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
@ -6,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Sample.SqlServer.DbContexts;
|
using Sample.SqlServer.DbContexts;
|
||||||
using Sample.SqlServer.Domain.Entities;
|
using Sample.SqlServer.Domain.Entities;
|
||||||
|
using ShardingCore.Core.QueryRouteManagers.Abstractions;
|
||||||
using ShardingCore.DbContexts.VirtualDbContexts;
|
using ShardingCore.DbContexts.VirtualDbContexts;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
|
||||||
|
@ -21,10 +23,12 @@ namespace Sample.SqlServer.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly DefaultShardingDbContext _defaultTableDbContext;
|
private readonly DefaultShardingDbContext _defaultTableDbContext;
|
||||||
|
private readonly IShardingRouteManager _shardingRouteManager;
|
||||||
|
|
||||||
public ValuesController(DefaultShardingDbContext defaultTableDbContext)
|
public ValuesController(DefaultShardingDbContext defaultTableDbContext,IShardingRouteManager shardingRouteManager)
|
||||||
{
|
{
|
||||||
_defaultTableDbContext = defaultTableDbContext;
|
_defaultTableDbContext = defaultTableDbContext;
|
||||||
|
_shardingRouteManager = shardingRouteManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
@ -56,11 +60,19 @@ namespace Sample.SqlServer.Controllers
|
||||||
_defaultTableDbContext.Attach(sysUserMod98);
|
_defaultTableDbContext.Attach(sysUserMod98);
|
||||||
sysUserMod98.Name = "name_update" + new Random().Next(1, 99) + "_98";
|
sysUserMod98.Name = "name_update" + new Random().Next(1, 99) + "_98";
|
||||||
await _defaultTableDbContext.SaveChangesAsync();
|
await _defaultTableDbContext.SaveChangesAsync();
|
||||||
var stu = new STU() { Id = "198"};
|
var stu = new STU() { Id = "198" };
|
||||||
var sresultx111x = _defaultTableDbContext.Set<SysUserMod>().FirstOrDefault(o => o.Id == stu.Id);
|
var sresultx111x = _defaultTableDbContext.Set<SysUserMod>().FirstOrDefault(o => o.Id == stu.Id);
|
||||||
|
|
||||||
var pageResult = await _defaultTableDbContext.Set<SysUserMod>().Skip(10).Take(10).OrderBy(o => o.Age).ToListAsync();
|
var pageResult = await _defaultTableDbContext.Set<SysUserMod>().Skip(10).Take(10).OrderBy(o => o.Age).ToListAsync();
|
||||||
return Ok(sresultx111);
|
|
||||||
|
|
||||||
|
using (_shardingRouteManager.CreateScope())
|
||||||
|
{
|
||||||
|
_shardingRouteManager.Current.Must.TryAdd(typeof(SysUserMod), new HashSet<string>() { "00" });
|
||||||
|
|
||||||
|
var mod00s = await _defaultTableDbContext.Set<SysUserMod>().Skip(10).Take(11).ToListAsync();
|
||||||
|
}
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,11 @@
|
||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Sample.SqlServer.Domain.Maps;
|
using Sample.SqlServer.Domain.Maps;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
|
|
||||||
namespace Sample.SqlServer.DbContexts
|
namespace Sample.SqlServer.DbContexts
|
||||||
{
|
{
|
||||||
public class DefaultTableDbContext: DbContext,IShardingTableDbContext
|
public class DefaultTableDbContext: DbContext, IShardingTableDbContext
|
||||||
{
|
{
|
||||||
public DefaultTableDbContext(DbContextOptions<DefaultTableDbContext> options) :base(options)
|
public DefaultTableDbContext(DbContextOptions<DefaultTableDbContext> options) :base(options)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace Sample.SqlServer.Shardings
|
||||||
*/
|
*/
|
||||||
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
public class SysUserModVirtualTableRoute : AbstractSimpleShardingModKeyStringVirtualTableRoute<SysUserMod>
|
||||||
{
|
{
|
||||||
|
protected override bool EnableHintRoute => true;
|
||||||
|
|
||||||
public SysUserModVirtualTableRoute() : base(2,3)
|
public SysUserModVirtualTableRoute() : base(2,3)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using Sample.SqlServer.Domain.Entities;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
|
|
||||||
namespace Sample.SqlServer.Shardings
|
namespace Sample.SqlServer.Shardings
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Sample.SqlServer3x.Domain.Maps;
|
using Sample.SqlServer3x.Domain.Maps;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
|
|
||||||
namespace Sample.SqlServer3x
|
namespace Sample.SqlServer3x
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using ShardingCore;
|
using ShardingCore;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
using ShardingCore.Core.VirtualTables;
|
using ShardingCore.Core.VirtualTables;
|
||||||
using ShardingCore.DbContexts;
|
using ShardingCore.DbContexts;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Samples.AutoByDate.SqlServer.Domain.Maps;
|
using Samples.AutoByDate.SqlServer.Domain.Maps;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
|
|
||||||
namespace Samples.AutoByDate.SqlServer.DbContexts
|
namespace Samples.AutoByDate.SqlServer.DbContexts
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
using System;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.RouteTails;
|
using ShardingCore.Core.VirtualRoutes.RouteTails;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
||||||
using ShardingCore.Exceptions;
|
using ShardingCore.Exceptions;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes
|
namespace ShardingCore.Core.VirtualRoutes
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Date: Sunday, 22 August 2021 14:58:58
|
* @Date: Sunday, 22 August 2021 14:58:58
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
public class RouteTailFactory:IRouteTailFactory
|
public class RouteTailFactory:IRouteTailFactory
|
||||||
{
|
{
|
||||||
public IRouteTail Create(string tail)
|
public IRouteTail Create(string tail)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.Abstractions
|
namespace ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Date: Sunday, 22 August 2021 09:44:54
|
* @Date: Sunday, 22 August 2021 09:44:54
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
public interface IMultiQueryRouteTail:IRouteTail
|
public interface IMultiQueryRouteTail:IRouteTail
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
namespace ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.Abstractions
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.Abstractions
|
namespace ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
namespace ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.Abstractions
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* @Author: xjm
|
||||||
|
* @Description:
|
||||||
|
* @Date: 2021/8/25 17:23:42
|
||||||
|
* @Ver: 1.0
|
||||||
|
* @Email: 326308290@qq.com
|
||||||
|
*/
|
||||||
|
public abstract class AbstractShardingAssertVirtualTableRoute<T, TKey> : AbstractVirtualTableRoute<T, TKey> where T : class, IShardingTable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ using ShardingCore.Exceptions;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
using ShardingCore.Utils;
|
using ShardingCore.Utils;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.TableRoutes
|
namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
|
@ -7,7 +7,7 @@ using ShardingCore.Core.QueryRouteManagers.Abstractions;
|
||||||
using ShardingCore.Exceptions;
|
using ShardingCore.Exceptions;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
|
||||||
namespace ShardingCore.Core.VirtualRoutes.TableRoutes
|
namespace ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
|
@ -17,7 +17,7 @@ using ShardingCore.Core.QueryRouteManagers.Abstractions;
|
||||||
using ShardingCore.Core.ShardingAccessors;
|
using ShardingCore.Core.ShardingAccessors;
|
||||||
using ShardingCore.Core.ShardingAccessors.Abstractions;
|
using ShardingCore.Core.ShardingAccessors.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
|
|
||||||
namespace ShardingCore
|
namespace ShardingCore
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
|
|
||||||
namespace ShardingCore.DbContexts.ShardingDbContexts
|
namespace ShardingCore.DbContexts.ShardingDbContexts
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ShardingCore.Core.ShardingAccessors.Abstractions;
|
using ShardingCore.Core.ShardingAccessors.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualTables;
|
using ShardingCore.Core.VirtualTables;
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
using ShardingCore.DbContexts.ShardingDbContexts;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
|
using ShardingCore.Core;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualTables;
|
||||||
|
using ShardingCore.DbContexts;
|
||||||
|
using ShardingCore.DbContexts.ShardingDbContexts;
|
||||||
|
using ShardingCore.Exceptions;
|
||||||
|
using ShardingCore.Extensions;
|
||||||
|
using ShardingCore.Sharding.Abstractions;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -5,23 +17,6 @@ using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ShardingCore.Core;
|
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.RouteTails;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
|
||||||
using ShardingCore.Core.VirtualTables;
|
|
||||||
using ShardingCore.DbContexts;
|
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
|
||||||
using ShardingCore.EFCores;
|
|
||||||
using ShardingCore.Exceptions;
|
|
||||||
using ShardingCore.Extensions;
|
|
||||||
using ShardingCore.Sharding.Abstractions;
|
|
||||||
|
|
||||||
namespace ShardingCore.Sharding
|
namespace ShardingCore.Sharding
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using System;
|
||||||
|
|
||||||
namespace ShardingCore.Sharding.Abstractions
|
namespace ShardingCore.Sharding.Abstractions
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Date: Saturday, 14 August 2021 21:47:11
|
* @Date: Saturday, 14 August 2021 21:47:11
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
public interface IShardingDbContext
|
public interface IShardingDbContext
|
||||||
{
|
{
|
||||||
Type ShardingDbContextType { get; }
|
Type ShardingDbContextType { get; }
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
|
||||||
|
|
||||||
namespace ShardingCore.Sharding.Abstractions
|
namespace ShardingCore.Sharding.Abstractions
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,13 +3,11 @@ using ShardingCore.Core.Internal.StreamMerge.ReWrite;
|
||||||
using ShardingCore.Core.Internal.Visitors;
|
using ShardingCore.Core.Internal.Visitors;
|
||||||
using ShardingCore.Core.Internal.Visitors.GroupBys;
|
using ShardingCore.Core.Internal.Visitors.GroupBys;
|
||||||
using ShardingCore.Core.Internal.Visitors.Selects;
|
using ShardingCore.Core.Internal.Visitors.Selects;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ShardingCore.Core.ShardingAccessors;
|
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
|
||||||
|
|
||||||
|
|
||||||
namespace ShardingCore.Sharding
|
namespace ShardingCore.Sharding
|
||||||
|
|
|
@ -2,7 +2,7 @@ using ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine;
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ShardingCore.Core.ShardingAccessors;
|
using ShardingCore.Core.ShardingAccessors;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
|
|
||||||
namespace ShardingCore.Sharding
|
namespace ShardingCore.Sharding
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ShardingCore.Core.PhysicTables;
|
using ShardingCore.Core.PhysicTables;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
using ShardingCore.Core.VirtualTables;
|
using ShardingCore.Core.VirtualTables;
|
||||||
using ShardingCore.DbContexts;
|
using ShardingCore.DbContexts;
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.Core.VirtualTables;
|
using ShardingCore.Core.VirtualTables;
|
||||||
using ShardingCore.DbContexts;
|
using ShardingCore.DbContexts;
|
||||||
using ShardingCore.DbContexts.Abstractions;
|
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
|
||||||
using ShardingCore.DbContexts.VirtualDbContexts;
|
|
||||||
using ShardingCore.Exceptions;
|
using ShardingCore.Exceptions;
|
||||||
using ShardingCore.Extensions;
|
using ShardingCore.Extensions;
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ShardingCore.TableCreator
|
namespace ShardingCore.TableCreator
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* @Author: xjm
|
* @Author: xjm
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Date: Monday, 21 December 2020 11:23:22
|
* @Date: Monday, 21 December 2020 11:23:22
|
||||||
* @Email: 326308290@qq.com
|
* @Email: 326308290@qq.com
|
||||||
*/
|
*/
|
||||||
public class ShardingTableCreator : IShardingTableCreator
|
public class ShardingTableCreator : IShardingTableCreator
|
||||||
{
|
{
|
||||||
private readonly ILogger<ShardingTableCreator> _logger;
|
private readonly ILogger<ShardingTableCreator> _logger;
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq.Expressions;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
|
|
||||||
namespace ShardingCore.VirtualRoutes.Abstractions
|
namespace ShardingCore.VirtualRoutes.Abstractions
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq.Expressions;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
|
|
||||||
namespace ShardingCore.VirtualRoutes.Abstractions
|
namespace ShardingCore.VirtualRoutes.Abstractions
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq.Expressions;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
|
|
||||||
namespace ShardingCore.VirtualRoutes.Mods
|
namespace ShardingCore.VirtualRoutes.Mods
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq.Expressions;
|
||||||
using ShardingCore.Core;
|
using ShardingCore.Core;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
using ShardingCore.Helpers;
|
using ShardingCore.Helpers;
|
||||||
|
|
||||||
namespace ShardingCore.VirtualRoutes.Mods
|
namespace ShardingCore.VirtualRoutes.Mods
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
using ShardingCore.Test50.MySql.Domain.Maps;
|
using ShardingCore.Test50.MySql.Domain.Maps;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ShardingCore.Core.VirtualRoutes.Abstractions;
|
using ShardingCore.Core.VirtualRoutes.RouteTails.Abstractions;
|
||||||
using ShardingCore.DbContexts.ShardingDbContexts;
|
using ShardingCore.DbContexts.ShardingDbContexts;
|
||||||
using ShardingCore.Sharding.Abstractions;
|
using ShardingCore.Sharding.Abstractions;
|
||||||
using ShardingCore.Test50.Domain.Maps;
|
using ShardingCore.Test50.Domain.Maps;
|
||||||
|
|
|
@ -247,6 +247,7 @@ namespace ShardingCore.Test50
|
||||||
|
|
||||||
var sysUserModDesc = await _virtualDbContext.Set<SysUserMod>().OrderByDescending(o => o.Id).FirstOrDefaultAsync();
|
var sysUserModDesc = await _virtualDbContext.Set<SysUserMod>().OrderByDescending(o => o.Id).FirstOrDefaultAsync();
|
||||||
Assert.True(sysUserModDesc != null && sysUserModDesc.Id == "999");
|
Assert.True(sysUserModDesc != null && sysUserModDesc.Id == "999");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -255,6 +256,10 @@ namespace ShardingCore.Test50
|
||||||
var sysUserMod = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "1").FirstOrDefaultAsync();
|
var sysUserMod = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "1").FirstOrDefaultAsync();
|
||||||
Assert.NotNull(sysUserMod);
|
Assert.NotNull(sysUserMod);
|
||||||
Assert.True(sysUserMod.Id == "1");
|
Assert.True(sysUserMod.Id == "1");
|
||||||
|
var user198 = await _virtualDbContext.Set<SysUserMod>().FirstOrDefaultAsync(o => o.Id == "198");
|
||||||
|
Assert.True(user198.Id == "198");
|
||||||
|
var userId198 = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "198").Select(o => o.Id).FirstOrDefaultAsync();
|
||||||
|
Assert.Equal(userId198, "198");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using ShardingCore.Core.VirtualRoutes;
|
using ShardingCore.Core.VirtualRoutes;
|
||||||
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
using ShardingCore.Core.VirtualRoutes.TableRoutes;
|
||||||
|
using ShardingCore.Core.VirtualRoutes.TableRoutes.Abstractions;
|
||||||
using ShardingCore.Test50.Domain.Entities;
|
using ShardingCore.Test50.Domain.Entities;
|
||||||
|
|
||||||
namespace ShardingCore.Test50.Shardings
|
namespace ShardingCore.Test50.Shardings
|
||||||
|
|
|
@ -249,6 +249,10 @@ namespace ShardingCore.Test50_2x
|
||||||
var sysUserMod = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "1").FirstOrDefaultAsync();
|
var sysUserMod = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "1").FirstOrDefaultAsync();
|
||||||
Assert.NotNull(sysUserMod);
|
Assert.NotNull(sysUserMod);
|
||||||
Assert.True(sysUserMod.Id == "1");
|
Assert.True(sysUserMod.Id == "1");
|
||||||
|
var user198 = await _virtualDbContext.Set<SysUserMod>().FirstOrDefaultAsync(o => o.Id == "198");
|
||||||
|
Assert.True(user198.Id == "198");
|
||||||
|
var userId198 = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "198").Select(o => o.Id).FirstOrDefaultAsync();
|
||||||
|
Assert.Equal(userId198, "198");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
@ -249,6 +249,10 @@ namespace ShardingCore.Test50_3x
|
||||||
var sysUserMod = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "1").FirstOrDefaultAsync();
|
var sysUserMod = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "1").FirstOrDefaultAsync();
|
||||||
Assert.NotNull(sysUserMod);
|
Assert.NotNull(sysUserMod);
|
||||||
Assert.True(sysUserMod.Id == "1");
|
Assert.True(sysUserMod.Id == "1");
|
||||||
|
var user198 = await _virtualDbContext.Set<SysUserMod>().FirstOrDefaultAsync(o => o.Id == "198");
|
||||||
|
Assert.True(user198.Id == "198");
|
||||||
|
var userId198 = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id == "198").Select(o => o.Id).FirstOrDefaultAsync();
|
||||||
|
Assert.Equal(userId198, "198");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Reference in New Issue