修复bug

This commit is contained in:
xuejiaming 2022-06-20 15:43:39 +08:00
parent 30d54fdf5f
commit 723fa6ca42
3 changed files with 29 additions and 13 deletions

View File

@ -3,6 +3,11 @@ using Microsoft.EntityFrameworkCore;
namespace Sample.AutoCreateIfPresent.Controllers;
public class AA
{
public string Id { get; set; }
public DateTime Time { get; set; }
}
[ApiController]
[Route("[controller]/[action]")]
public class TestController : ControllerBase
@ -23,6 +28,14 @@ public class TestController : ControllerBase
public async Task<IActionResult> Query()
{
var aas = new List<AA>();
var ids = new []{"雪花id1","雪花id2"};
var time1 = new DateTime(2021,1,1);
var time2 = new DateTime(2022,1,1);
var enumerable = aas.Where(o=>ids.Contains(o.Id)&&o.Time>=time1&&o.Time<=time2);
var enumerable1 = aas.Where(o=>o.Id=="雪花id1"||o.Id=="雪花id2");
var enumerable2 = aas.Where(o=>o.Id=="雪花id1"&&o.Id=="雪花id2");
var list =await _defaultDbContext.Set<OrderByHour>().ToListAsync();
return Ok(list);
}

View File

@ -69,7 +69,7 @@ namespace Sample.MySql
{
op.ConfigId = "c1";
op.AddDefaultDataSource("ds0",
"server=127.0.0.1;port=3306;database=dbxxxx;userid=root;password=root;");
"server=127.0.0.1;port=3307;database=dbxxxx;userid=root;password=root;");
//op.AddDefaultDataSource("ds0", "server=127.0.0.1;port=3306;database=db2;userid=root;password=L6yBtV6qNENrwBy7;")
op.ReplaceTableEnsureManager(sp=>new MySqlTableEnsureManager<DefaultShardingDbContext>());

View File

@ -92,6 +92,8 @@ namespace ShardingCore.VirtualRoutes.Abstractions
dataSources.Add(virtualDataSource.DefaultDataSourceName);
}
_logger.LogInformation($"auto create table data source names:[{string.Join(",", dataSources)}]");
using (virtualDataSourceManager.CreateScope(virtualDataSource.ConfigId))
{
foreach (var dataSource in dataSources)
{
try
@ -109,6 +111,7 @@ namespace ShardingCore.VirtualRoutes.Abstractions
}
}
}
}
return Task.CompletedTask;
}