## v0.12.5

This commit is contained in:
28810 2019-11-25 22:33:44 +08:00
parent 20e06ef3a2
commit bfed0cd124
17 changed files with 21 additions and 27 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>BaseEntity 是一种极简单的 CodeFirst 开发方式特别对单表或多表CRUD利用继承节省了每个实体类的重复属性创建时间、ID等字段软件删除等功能进行 crud 操作时不必时常考虑仓储的使用.</Description> <Description>BaseEntity 是一种极简单的 CodeFirst 开发方式特别对单表或多表CRUD利用继承节省了每个实体类的重复属性创建时间、ID等字段软件删除等功能进行 crud 操作时不必时常考虑仓储的使用.</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 扩展包可实现实体类属性为对象时以JSON形式映射存储.</Description> <Description>FreeSql 扩展包可实现实体类属性为对象时以JSON形式映射存储.</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 扩展包,可实现【延时加载】属性.</Description> <Description>FreeSql 扩展包,可实现【延时加载】属性.</Description>

View File

@ -107,8 +107,9 @@ namespace FreeSql
internal ConcurrentDictionary<string, EntityState> _statesInternal => _states; internal ConcurrentDictionary<string, EntityState> _statesInternal => _states;
TableInfo _tablePriv; TableInfo _tablePriv;
protected TableInfo _table => _tablePriv ?? (_tablePriv = _db.Orm.CodeFirst.GetTableByEntity(_entityType)); protected TableInfo _table => _tablePriv ?? (_tablePriv = _db.Orm.CodeFirst.GetTableByEntity(_entityType));
ColumnInfo[] _tableIdentitysPriv; ColumnInfo[] _tableIdentitysPriv, _tableServerTimesPriv;
protected ColumnInfo[] _tableIdentitys => _tableIdentitysPriv ?? (_tableIdentitysPriv = _table.Primarys.Where(a => a.Attribute.IsIdentity).ToArray()); protected ColumnInfo[] _tableIdentitys => _tableIdentitysPriv ?? (_tableIdentitysPriv = _table.Primarys.Where(a => a.Attribute.IsIdentity).ToArray());
protected ColumnInfo[] _tableServerTimes => _tableServerTimesPriv ?? (_tableServerTimesPriv = _table.Primarys.Where(a => a.Attribute.ServerTime != DateTimeKind.Unspecified).ToArray());
protected Type _entityType = typeof(TEntity); protected Type _entityType = typeof(TEntity);
public Type EntityType => _entityType; public Type EntityType => _entityType;
@ -125,6 +126,7 @@ namespace FreeSql
_entityType = entityType; _entityType = entityType;
_tablePriv = newtb ?? throw new Exception("DbSet.AsType 参数错误,请传入正确的实体类型"); _tablePriv = newtb ?? throw new Exception("DbSet.AsType 参数错误,请传入正确的实体类型");
_tableIdentitysPriv = null; _tableIdentitysPriv = null;
_tableServerTimesPriv = null;
return this; return this;
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <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> <Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description> <Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl> <PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>

View File

@ -72,17 +72,9 @@ namespace FreeSql.DataAnnotations
/// </summary> /// </summary>
public bool CanUpdate { get => _CanUpdate ?? true; set => _CanUpdate = value; } public bool CanUpdate { get => _CanUpdate ?? true; set => _CanUpdate = value; }
internal DateTimeKind? _ServerTime;
/// <summary> /// <summary>
/// 标记属性为数据库服务器时间(utc/local),在插入的时候使用类似 getdate() 执行 /// 标记属性为数据库服务器时间(utc/local),在插入的时候使用类似 getdate() 执行
/// </summary> /// </summary>
public DateTimeKind ServerTime public DateTimeKind ServerTime { get; set; }
{
get => _ServerTime ?? DateTimeKind.Local;
set
{
_ServerTime = value == DateTimeKind.Unspecified ? DateTimeKind.Local : value;
}
}
} }
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <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> <Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>

View File

@ -128,7 +128,7 @@ namespace FreeSql.Internal
if (trycol._Position != null) attr._Position = trycol.Position; if (trycol._Position != null) attr._Position = trycol.Position;
if (trycol._CanInsert != null) attr._CanInsert = trycol.CanInsert; if (trycol._CanInsert != null) attr._CanInsert = trycol.CanInsert;
if (trycol._CanUpdate != null) attr._CanUpdate = trycol.CanUpdate; 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); var attrs = proto.GetCustomAttributes(typeof(ColumnAttribute), false);
foreach (var tryattrobj in attrs) foreach (var tryattrobj in attrs)
@ -147,7 +147,7 @@ namespace FreeSql.Internal
if (tryattr._Position != null) attr._Position = tryattr.Position; if (tryattr._Position != null) attr._Position = tryattr.Position;
if (tryattr._CanInsert != null) attr._CanInsert = tryattr.CanInsert; if (tryattr._CanInsert != null) attr._CanInsert = tryattr.CanInsert;
if (tryattr._CanUpdate != null) attr._CanUpdate = tryattr.CanUpdate; 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; ColumnAttribute ret = null;
if (!string.IsNullOrEmpty(attr.Name)) ret = attr; if (!string.IsNullOrEmpty(attr.Name)) ret = attr;
@ -162,7 +162,7 @@ namespace FreeSql.Internal
if (attr._Position != null) ret = attr; if (attr._Position != null) ret = attr;
if (attr._CanInsert != null) ret = attr; if (attr._CanInsert != null) ret = attr;
if (attr._CanUpdate != 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; if (ret != null && ret.MapType == null) ret.MapType = proto.PropertyType;
return ret; return ret;
} }

View File

@ -189,7 +189,7 @@ namespace FreeSql.Internal
// else if (Math.Abs(dt.Subtract(DateTime.UtcNow).TotalSeconds) < 60) // else if (Math.Abs(dt.Subtract(DateTime.UtcNow).TotalSeconds) < 60)
// col.DbDefaultValue = common.NowUtc; // 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.DbDefaultValue = colattr.ServerTime == DateTimeKind.Local ? common.Now : common.NowUtc;
col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? common.Now : common.NowUtc; col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? common.Now : common.NowUtc;

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net452;net451;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description> <Description>FreeSql 数据库实现,基于 MySql 5.6</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description> <Description>FreeSql 数据库实现,基于 MySql 5.6</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库 Odbc 实现,基于 {Oracle}、{SQL Server}、{MySQL ODBC 8.0 Unicode Driver}、{PostgreSQL Unicode(x64)} 专用访问实现,以及通用 Odbc 访问所有数据库</Description> <Description>FreeSql 数据库 Odbc 实现,基于 {Oracle}、{SQL Server}、{MySQL ODBC 8.0 Unicode Driver}、{PostgreSQL Unicode(x64)} 专用访问实现,以及通用 Odbc 访问所有数据库</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库实现,基于 Oracle 11</Description> <Description>FreeSql 数据库实现,基于 Oracle 11</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net461;net452;net451;net45</TargetFrameworks> <TargetFrameworks>netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description> <Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net451;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net451;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库实现,基于 SqlServer 2005+并根据版本适配分页方法row_number 或 offset fetch next</Description> <Description>FreeSql 数据库实现,基于 SqlServer 2005+并根据版本适配分页方法row_number 或 offset fetch next</Description>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks> <TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>0.12.4</Version> <Version>0.12.5</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 数据库实现,基于 Sqlite 3.0,支持 .NetCore、.NetFramework、Xamarin</Description> <Description>FreeSql 数据库实现,基于 Sqlite 3.0,支持 .NetCore、.NetFramework、Xamarin</Description>