mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-25 01:14:33 +08:00
Update 人大金仓
This commit is contained in:
parent
81850db4ef
commit
129d891b1c
57
Src/Asp.NetCore2/KdbndpTest/UnitTest/UInsert3.cs
Normal file
57
Src/Asp.NetCore2/KdbndpTest/UnitTest/UInsert3.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlTypes;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Principal;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
internal class UInsert3
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
db.Insertable(new Order() { Name = "a" }).ExecuteCommand();
|
||||||
|
|
||||||
|
db.Insertable(new List<Order>() {
|
||||||
|
new Order() { Name = "a" },
|
||||||
|
new Order() { Name = "a" }
|
||||||
|
}).ExecuteCommand();
|
||||||
|
|
||||||
|
db.Insertable(new ORDER() { Name = "a" }).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Order
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 姓名
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
[SugarColumn(InsertServerTime =true)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int CustomId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ORDER
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 姓名
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
[SugarColumn(InsertSql = "'2020-1-1'")]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int CustomId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,7 @@ namespace SqlSugar
|
|||||||
string columnsString = string.Join(",", groupList.First().Select(it => Builder.GetTranslationColumnName(it.DbColumnName)));
|
string columnsString = string.Join(",", groupList.First().Select(it => Builder.GetTranslationColumnName(it.DbColumnName)));
|
||||||
if (isSingle)
|
if (isSingle)
|
||||||
{
|
{
|
||||||
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it => Builder.SqlParameterKeyWord + it.DbColumnName));
|
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it =>base.GetDbColumn(it, Builder.SqlParameterKeyWord + it.DbColumnName)));
|
||||||
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
|
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -66,6 +66,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
batchInsetrSql.Append("\r\n ( " + string.Join(",", columns.Select(it =>
|
batchInsetrSql.Append("\r\n ( " + string.Join(",", columns.Select(it =>
|
||||||
{
|
{
|
||||||
|
if (it.InsertServerTime || it.InsertSql.HasValue())
|
||||||
|
{
|
||||||
|
return GetDbColumn(it, null);
|
||||||
|
}
|
||||||
object value = null;
|
object value = null;
|
||||||
if (it.Value is DateTime)
|
if (it.Value is DateTime)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user