mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 20:38:16 +08:00
## v0.12.5
This commit is contained in:
@ -72,17 +72,9 @@ namespace FreeSql.DataAnnotations
|
||||
/// </summary>
|
||||
public bool CanUpdate { get => _CanUpdate ?? true; set => _CanUpdate = value; }
|
||||
|
||||
internal DateTimeKind? _ServerTime;
|
||||
/// <summary>
|
||||
/// 标记属性为数据库服务器时间(utc/local),在插入的时候使用类似 getdate() 执行
|
||||
/// </summary>
|
||||
public DateTimeKind ServerTime
|
||||
{
|
||||
get => _ServerTime ?? DateTimeKind.Local;
|
||||
set
|
||||
{
|
||||
_ServerTime = value == DateTimeKind.Unspecified ? DateTimeKind.Local : value;
|
||||
}
|
||||
}
|
||||
public DateTimeKind ServerTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<Version>0.12.4</Version>
|
||||
<Version>0.12.5</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>
|
||||
|
@ -128,7 +128,7 @@ namespace FreeSql.Internal
|
||||
if (trycol._Position != null) attr._Position = trycol.Position;
|
||||
if (trycol._CanInsert != null) attr._CanInsert = trycol.CanInsert;
|
||||
if (trycol._CanUpdate != null) attr._CanUpdate = trycol.CanUpdate;
|
||||
if (trycol._ServerTime != null) attr._ServerTime = trycol._ServerTime;
|
||||
if (trycol.ServerTime != DateTimeKind.Unspecified) attr.ServerTime = trycol.ServerTime;
|
||||
}
|
||||
var attrs = proto.GetCustomAttributes(typeof(ColumnAttribute), false);
|
||||
foreach (var tryattrobj in attrs)
|
||||
@ -147,7 +147,7 @@ namespace FreeSql.Internal
|
||||
if (tryattr._Position != null) attr._Position = tryattr.Position;
|
||||
if (tryattr._CanInsert != null) attr._CanInsert = tryattr.CanInsert;
|
||||
if (tryattr._CanUpdate != null) attr._CanUpdate = tryattr.CanUpdate;
|
||||
if (tryattr._ServerTime != null) attr._ServerTime = tryattr.ServerTime;
|
||||
if (tryattr.ServerTime != DateTimeKind.Unspecified) attr.ServerTime = tryattr.ServerTime;
|
||||
}
|
||||
ColumnAttribute ret = null;
|
||||
if (!string.IsNullOrEmpty(attr.Name)) ret = attr;
|
||||
@ -162,7 +162,7 @@ namespace FreeSql.Internal
|
||||
if (attr._Position != null) ret = attr;
|
||||
if (attr._CanInsert != null) ret = attr;
|
||||
if (attr._CanUpdate != null) ret = attr;
|
||||
if (attr._ServerTime != null) ret = attr;
|
||||
if (attr.ServerTime != DateTimeKind.Unspecified) ret = attr;
|
||||
if (ret != null && ret.MapType == null) ret.MapType = proto.PropertyType;
|
||||
return ret;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace FreeSql.Internal
|
||||
// else if (Math.Abs(dt.Subtract(DateTime.UtcNow).TotalSeconds) < 60)
|
||||
// col.DbDefaultValue = common.NowUtc;
|
||||
//}
|
||||
if (colattr._ServerTime != null && new[] { typeof(DateTime), typeof(DateTimeOffset) }.Contains(colattr.MapType.NullableTypeOrThis()))
|
||||
if (colattr.ServerTime != DateTimeKind.Unspecified && new[] { typeof(DateTime), typeof(DateTimeOffset) }.Contains(colattr.MapType.NullableTypeOrThis()))
|
||||
{
|
||||
col.DbDefaultValue = colattr.ServerTime == DateTimeKind.Local ? common.Now : common.NowUtc;
|
||||
col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? common.Now : common.NowUtc;
|
||||
|
Reference in New Issue
Block a user