mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-31 15:56:25 +08:00
Update DbFastest SqlServer DateTimeOffset
This commit is contained in:
parent
6ce8bc5e36
commit
f6d36510a1
@ -10,6 +10,7 @@ namespace SqlSugar
|
||||
public class FastBuilder
|
||||
{
|
||||
public virtual bool IsActionUpdateColumns { get; set; }
|
||||
public virtual DbFastestProperties DbFastestProperties { get; set; }
|
||||
public SqlSugarProvider Context { get; set; }
|
||||
public virtual string CharacterSet { get; set; }
|
||||
public virtual string UpdateSql { get; set; } = @"UPDATE TM
|
||||
|
@ -42,6 +42,7 @@ namespace SqlSugar
|
||||
}
|
||||
private DataTable ToDdateTable(List<T> datas)
|
||||
{
|
||||
var builder = GetBuider();
|
||||
DataTable tempDataTable = ReflectionInoCore<DataTable>.GetInstance().GetOrCreate("BulkCopyAsync" + typeof(T).FullName,
|
||||
() =>
|
||||
{
|
||||
@ -87,7 +88,14 @@ namespace SqlSugar
|
||||
}
|
||||
else if (column.UnderType == UtilConstants.DateTimeOffsetType&& value!=null && value != DBNull.Value)
|
||||
{
|
||||
value = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
||||
if (builder.DbFastestProperties != null && builder.DbFastestProperties.HasOffsetTime == true)
|
||||
{
|
||||
//Don't need to deal with
|
||||
}
|
||||
else
|
||||
{
|
||||
value = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
||||
}
|
||||
}
|
||||
dr[name] = value;
|
||||
}
|
||||
|
13
Src/Asp.Net/SqlSugar/Entities/DbFastestProperties.cs
Normal file
13
Src/Asp.Net/SqlSugar/Entities/DbFastestProperties.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class DbFastestProperties
|
||||
{
|
||||
public bool HasOffsetTime { get; set; }
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ namespace SqlSugar
|
||||
public interface IFastBuilder
|
||||
{
|
||||
bool IsActionUpdateColumns { get; set; }
|
||||
DbFastestProperties DbFastestProperties { get; set; }
|
||||
SqlSugarProvider Context { get; set; }
|
||||
string CharacterSet { get; set; }
|
||||
Task<int> UpdateByTempAsync(string tableName,string tempName,string [] updateColumns,string[] whereColumns);
|
||||
|
@ -17,6 +17,7 @@ namespace SqlSugar
|
||||
|
||||
public SqlSugarProvider Context { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public bool IsActionUpdateColumns { get; set; }
|
||||
public DbFastestProperties DbFastestProperties { get; set; } = new DbFastestProperties();
|
||||
|
||||
public void CloseDb()
|
||||
{
|
||||
|
@ -6,6 +6,17 @@ namespace SqlSugar
|
||||
{
|
||||
public class SqlServerDbBind : DbBindProvider
|
||||
{
|
||||
public override string GetDbTypeName(string csharpTypeName)
|
||||
{
|
||||
if (csharpTypeName == nameof(DateTimeOffset))
|
||||
{
|
||||
return nameof(DateTimeOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.GetDbTypeName(csharpTypeName);
|
||||
}
|
||||
}
|
||||
public override List<KeyValuePair<string, CSharpDataType>> MappingTypes
|
||||
{
|
||||
get
|
||||
|
@ -12,6 +12,9 @@ namespace SqlSugar
|
||||
public class SqlServerFastBuilder:FastBuilder,IFastBuilder
|
||||
{
|
||||
public override bool IsActionUpdateColumns { get; set; } = true;
|
||||
public override DbFastestProperties DbFastestProperties { get; set; } = new DbFastestProperties() {
|
||||
HasOffsetTime=true
|
||||
};
|
||||
public async Task<int> ExecuteBulkCopyAsync(DataTable dt)
|
||||
{
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace SqlSugar
|
||||
public string CharacterSet { get; set; }
|
||||
private DataTable UpdateDataTable { get; set; }
|
||||
public bool IsActionUpdateColumns { get; set; }
|
||||
public DbFastestProperties DbFastestProperties { get; set; } = new DbFastestProperties();
|
||||
public SqliteFastBuilder(EntityInfo entityInfo)
|
||||
{
|
||||
this.entityInfo = entityInfo;
|
||||
|
@ -103,6 +103,7 @@
|
||||
<Compile Include="Abstract\SaveableProvider\StorageableDataTable.cs" />
|
||||
<Compile Include="Abstract\SugarProvider\SqlSugarCoreProvider.cs" />
|
||||
<Compile Include="Abstract\UpdateProvider\SplitTableUpdateByObjectProvider.cs" />
|
||||
<Compile Include="Entities\DbFastestProperties.cs" />
|
||||
<Compile Include="Json2Sql\Entities\JsonDeleteResult.cs" />
|
||||
<Compile Include="Json2Sql\Entities\JsonInsertResult.cs" />
|
||||
<Compile Include="Json2Sql\Entities\JsonQueryResult.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user