dotnetcore / dotnetcore/FreeSql

Insert ... ExecuteSqlBulkCopy() 对于表名 'tb topic' 有空格的情况拼接sql语句有错误,没正确添加 [tb topic] 中括号

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

Description

![Image](https://github.com/user-attachments/assets/6a501ae9-3ad0-475c-8daa-3d41180427b9)

测试代码

```
using FreeSql;
using FreeSql.DataAnnotations;
using System.Diagnostics;

class Program
{
private static Lazy sqlserverLazy = new Lazy(() => new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=ds_shop;Pooling=true;Max Pool Size=3")
.UseAutoSyncStructure(true)
.UseMonitorCommand(
cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
)
.UseLazyLoading(true)
.Build());

private static IInsert insert => sqlserverLazy.Value.Insert();

static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
var items = new List();
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });

insert.AppendData(items).InsertIdentity().ExecuteSqlBulkCopy();
}
}

[Table(Name = "tb topic")]
class Topic
{
[Column(IsIdentity = true, IsPrimary = true)]
public int Id { get; set; }
public int Clicks { get; set; }
public int TypeGuid { get; set; }
public string Title { get; set; }
public DateTime CreateTime { get; set; }
}

```

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.