dotnetcore / dotnetcore/FreeSql

clickhouse批量插入失败

Open
#1,882 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

在使用最新版的clickhouse.client驱动7.7.3时,使用批量删除失败。
通过跟踪源代码发现是因为freesql转换的DataTable的字段顺序和clickhouse.client不一样导致的。

这个原因请问该如何解决?

freesql InsertProvider文件的ToDataTable方法
![image](https://github.com/user-attachments/assets/51650999-b48c-49e0-9bab-8b2d5c0291fc)

clickhouse.client ClickHouseBulkCopy文件的LoadNamesAndTypesAsync 方法
![image](https://github.com/user-attachments/assets/c7cb4ae1-5457-458b-ae66-0fd3c6a6d04f)
![image](https://github.com/user-attachments/assets/9c7a5070-1285-4251-a102-2338fd7b1510)

clickhouse.client ClickHouseBulkCopy文件的SerializeBatch
![image](https://github.com/user-attachments/assets/57388961-c41e-41a0-93ad-f833cca86cd6)
![image](https://github.com/user-attachments/assets/644b333c-82a0-4927-a9a6-16ee5b171c89)

#### 问题描述及重现代码:

```c#

_fsql.Insert(list).NoneParameter().ExecuteAffrows();

实体如下
[Table(Name = "sys_api_log")]
public class ApiLogEntity
{

[Column(IsPrimary = true, Name = "id", CanUpdate = false)]
public string Id { set; get; }


[Column(Name = "ct", ServerTime = DateTimeKind.Local, CanUpdate = false)]
[JsonProperty("ct")]
public DateTime CreateTime { set; get; }


[Column(Name = "uid")]
[JsonProperty("uid")]
public string UserId { set; get; }

///
/// url
///
[Column(Name = "url")]
[JsonProperty("url")]
public string? Url { set; get; }

[Column(Name = "ip")]
[JsonProperty("ip")]
public string IP { set; get; }

[Column(Name = "body")]
[JsonProperty("body")]
public string Body { set; get; }

[Column(Name = "take_time")]
[JsonProperty("take_time")]
public int TakeTime { get; set; }

[Column(Name = "code")]
[JsonProperty("code")]
public int Code { get; set; }
}
```

#### 数据库版本

clickhouse 23
#### 安装的Nuget包

3.2.833
#### .net framework/. net core? 及具体版本

.net 8

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.