Skip to content

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

@densen2014

Description

@densen2014

Image

测试代码

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




class Program
{
    private static Lazy<IFreeSql> sqlserverLazy = new Lazy<IFreeSql>(() => 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<Topic> insert => sqlserverLazy.Value.Insert<Topic>();

    static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
        var items = new List<Topic>();
        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; }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions