移除 FreeSql.DbContext,成为独立项目

This commit is contained in:
28810
2019-04-01 10:48:39 +08:00
parent 3ca91b70a9
commit be5259dd68
32 changed files with 35 additions and 1862 deletions

View File

@ -304,6 +304,37 @@ namespace FreeSql.Extensions.EntityUtil {
func(item);
}
static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object>>> _dicClearEntityPrimaryValueWithIdentity = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object>>>();
/// <summary>
/// 清除实体的主键值将自增、Guid类型的主键值清除
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <param name="orm"></param>
/// <param name="item"></param>
public static void ClearEntityPrimaryValueWithIdentity<TEntity>(this IFreeSql orm, TEntity item) {
var func = _dicClearEntityPrimaryValueWithIdentity.GetOrAdd(orm.Ado.DataType, dt => new ConcurrentDictionary<Type, Action<object>>()).GetOrAdd(typeof(TEntity), t => {
var _table = orm.CodeFirst.GetTableByEntity(t);
var identitys = _table.Primarys.Where(a => a.Attribute.IsIdentity);
var parm1 = Expression.Parameter(typeof(object));
var var1Parm = Expression.Variable(t);
var exps = new List<Expression>(new Expression[] {
Expression.Assign(var1Parm, Expression.TypeAs(parm1, t))
});
foreach (var pk in _table.Primarys) {
if (pk.Attribute.IsIdentity) {
exps.Add(
Expression.Assign(
Expression.MakeMemberAccess(var1Parm, _table.Properties[pk.CsName]),
Expression.Default(pk.CsType)
)
);
}
}
return Expression.Lambda<Action<object>>(Expression.Block(new[] { var1Parm }, exps), new[] { parm1 }).Compile();
});
func(item);
}
static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Func<object, object, bool, string[]>>> _dicCompareEntityValueReturnColumns = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Func<object, object, bool, string[]>>>();
/// <summary>
/// 对比两个实体值,返回相同/或不相同的列名

View File

@ -1,44 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.3.14</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors>
<Description>打造 .NETCore 最方便的 ORMDbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite读写分离、分表分库。</Description>
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
<PackageTags>FreeSql ORM</PackageTags>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Oracle\**" />
<Compile Remove="PostgreSQL\**" />
<Compile Remove="Sqlite\**" />
<Compile Remove="SqlServer\**" />
<EmbeddedResource Remove="Oracle\**" />
<EmbeddedResource Remove="PostgreSQL\**" />
<EmbeddedResource Remove="Sqlite\**" />
<EmbeddedResource Remove="SqlServer\**" />
<None Remove="Oracle\**" />
<None Remove="PostgreSQL\**" />
<None Remove="Sqlite\**" />
<None Remove="SqlServer\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="FreeSqlBuilder.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CS-Script.Core" Version="1.0.6" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="Npgsql.LegacyPostgis" Version="4.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="SafeObjectPool" Version="2.0.1" />
</ItemGroup>
</Project>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.3.27</Version>
<Version>0.4.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors>
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>