mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
v3.2.666-preview20220803 修复 Clickhouse Insert AsTable 表名处理 bug;
This commit is contained in:
parent
7ce0764670
commit
034b4735f4
@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>3.2.666-preview20220802</Version>
|
<Version>3.2.666-preview20220803</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -296,6 +296,22 @@ namespace base_entity
|
|||||||
Task.WaitAll(tasks.ToArray());
|
Task.WaitAll(tasks.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TreeModel
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public int parentid { get; set; }
|
||||||
|
public string code { get; set; }
|
||||||
|
|
||||||
|
[Navigate(nameof(parentid))]
|
||||||
|
public TreeModel Parent { get; set; }
|
||||||
|
[Navigate(nameof(parentid))]
|
||||||
|
public List<TreeModel> Childs { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class DateModel
|
||||||
|
{
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
}
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
#region 初始化 IFreeSql
|
#region 初始化 IFreeSql
|
||||||
@ -345,11 +361,40 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
fsql.CodeFirst.ConfigEntity<User1>(a =>
|
||||||
|
{
|
||||||
|
a.Name("FSCHEDULER");
|
||||||
|
});
|
||||||
|
|
||||||
|
var dates = Enumerable.Range(0, 5)
|
||||||
|
.Select(a => new DateModel { Date = DateTime.Parse("2022-08-01").AddDays(a) })
|
||||||
|
.ToArray();
|
||||||
|
var datesSql1 = fsql.Select<User1>()
|
||||||
|
.GroupBy(a => a.CreateTime.Date)
|
||||||
|
.WithTempQuery(a => new
|
||||||
|
{
|
||||||
|
date = a.Key,
|
||||||
|
sum1 = a.Sum(a.Value.Nickname.Length)
|
||||||
|
})
|
||||||
|
.FromQuery(fsql.Select<DateModel>().WithMemory(dates))
|
||||||
|
.RightJoin((a, b) => a.date == b.Date)
|
||||||
|
.ToSql();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var treeSql1 = fsql.Select<TreeModel>()
|
||||||
|
.WhereCascade(a => a.code == "xxx")
|
||||||
|
.Where(a => a.id == 123)
|
||||||
|
.AsTreeCte()
|
||||||
|
.ToSql();
|
||||||
|
|
||||||
var list = new List<User1>();
|
var list = new List<User1>();
|
||||||
list.Add(new User1 { Id = Guid.NewGuid() });
|
list.Add(new User1 { Id = Guid.NewGuid() });
|
||||||
list.Add(new User1 { Id = Guid.NewGuid() });
|
list.Add(new User1 { Id = Guid.NewGuid() });
|
||||||
list.Add(new User1 { Id = Guid.NewGuid() });
|
list.Add(new User1 { Id = Guid.NewGuid() });
|
||||||
|
|
||||||
|
var listSql3 = fsql.InsertOrUpdate<User1>().IfExistsDoNothing().SetSource(list).ToSql();
|
||||||
|
|
||||||
var listSql = fsql.Select<User1>()
|
var listSql = fsql.Select<User1>()
|
||||||
.WithMemory(list)
|
.WithMemory(list)
|
||||||
.ToSql();
|
.ToSql();
|
||||||
|
@ -57,14 +57,14 @@ namespace FreeSql.ClickHouse.Curd
|
|||||||
{
|
{
|
||||||
before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, null, _params);
|
before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, null, _params);
|
||||||
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
||||||
|
var data = ToDataTable();
|
||||||
using (var conn = _orm.Ado.MasterPool.Get())
|
using (var conn = _orm.Ado.MasterPool.Get())
|
||||||
{
|
{
|
||||||
using var bulkCopyInterface = new ClickHouseBulkCopy(conn.Value as ClickHouseConnection)
|
using var bulkCopyInterface = new ClickHouseBulkCopy(conn.Value as ClickHouseConnection)
|
||||||
{
|
{
|
||||||
DestinationTableName = _table.DbName,
|
DestinationTableName = data.TableName,
|
||||||
BatchSize = _source.Count
|
BatchSize = _source.Count
|
||||||
};
|
};
|
||||||
var data = ToDataTable();
|
|
||||||
bulkCopyInterface.WriteToServerAsync(data, default).Wait();
|
bulkCopyInterface.WriteToServerAsync(data, default).Wait();
|
||||||
}
|
}
|
||||||
return affrows;
|
return affrows;
|
||||||
@ -167,14 +167,14 @@ namespace FreeSql.ClickHouse.Curd
|
|||||||
{
|
{
|
||||||
before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, null, _params);
|
before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, null, _params);
|
||||||
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
||||||
|
var data = ToDataTable();
|
||||||
using (var conn = await _orm.Ado.MasterPool.GetAsync())
|
using (var conn = await _orm.Ado.MasterPool.GetAsync())
|
||||||
{
|
{
|
||||||
using var bulkCopyInterface = new ClickHouseBulkCopy(conn.Value as ClickHouseConnection)
|
using var bulkCopyInterface = new ClickHouseBulkCopy(conn.Value as ClickHouseConnection)
|
||||||
{
|
{
|
||||||
DestinationTableName = _table.DbName,
|
DestinationTableName = data.TableName,
|
||||||
BatchSize = _source.Count
|
BatchSize = _source.Count
|
||||||
};
|
};
|
||||||
var data = ToDataTable();
|
|
||||||
await bulkCopyInterface.WriteToServerAsync(data, default);
|
await bulkCopyInterface.WriteToServerAsync(data, default);
|
||||||
}
|
}
|
||||||
return affrows;
|
return affrows;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user