Skip to content

Commit

Permalink
v1.7.1(兼容问题 Microsoft.Data.SqliClient) #394 #384 #330 #115 #17
Browse files Browse the repository at this point in the history
  • Loading branch information
28810 authored and 28810 committed Aug 1, 2020
1 parent fee937a commit f897aa0
Show file tree
Hide file tree
Showing 25 changed files with 142 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql 扩展包,可实现实体类属性为对象时,以JSON形式映射存储.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql 扩展包,可实现【延时加载】属性.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql 扩展包,实现 linq queryable 和 linq to sql 语法进行开发.</Description>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/FreeSql.Generator/FreeSql.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Description>使用 FreeSql 快速生成数据库的实体类,安装:dotnet tool install -g FreeSql.Generator</Description>
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion FreeSql.All/FreeSql.All.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql 全家桶,懒人专用</Description>
Expand Down
3 changes: 2 additions & 1 deletion FreeSql.DbContext/DbSet/DbSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void Dispose()
{
this._dicUpdateTimes.Clear();
this._states.Clear();
this._statesEditing.Clear();
this._dataEditing = null;
}
finally
{
Expand Down Expand Up @@ -123,7 +125,6 @@ internal void TrackToList(object list)
public ISelect<TEntity> WhereIf(bool condition, Expression<Func<TEntity, bool>> exp) => this.OrmSelect(null).WhereIf(condition, exp);

protected ConcurrentDictionary<string, EntityState> _states = new ConcurrentDictionary<string, EntityState>();
internal ConcurrentDictionary<string, EntityState> _statesInternal => _states;
TableInfo _tablePriv;
protected TableInfo _table => _tablePriv ?? (_tablePriv = _db.OrmOriginal.CodeFirst.GetTableByEntity(_entityType));
ColumnInfo[] _tableIdentitysPriv, _tableServerTimesPriv;
Expand Down
86 changes: 86 additions & 0 deletions FreeSql.DbContext/DbSet/DbSetSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,5 +530,91 @@ public void AddOrUpdate(TEntity data)
}
}
#endregion

#region BeginEdit
protected List<TEntity> _dataEditing;
protected ConcurrentDictionary<string, EntityState> _statesEditing = new ConcurrentDictionary<string, EntityState>();

/// <summary>
/// 开始编辑数据,然后调用方法 EndEdit 分析出添加、修改、删除 SQL 语句进行执行<para></para>
/// 场景:winform 加载表数据后,一顿添加、修改、删除操作之后,最后才点击【保存】<para></para><para></para>
/// 示例:https://github.com/dotnetcore/FreeSql/issues/397<para></para>
/// </summary>
/// <param name="data"></param>
//public void BeginEdit(List<TEntity> data)
//{
// if (data == null || data.Any() == false) return;
// if (_table.Primarys.Any() == false) throw new Exception($"不可进行编辑,实体没有主键:{_db.OrmOriginal.GetEntityString(_entityType, data.First())}");
// _statesEditing.Clear();
// _dataEditing = data;
// foreach (var item in data)
// {
// var key = _db.OrmOriginal.GetEntityKeyString(_entityType, item, false);
// if (string.IsNullOrEmpty(key)) continue;

// _statesEditing.AddOrUpdate(key, k => CreateEntityState(item), (k, ov) =>
// {
// _db.OrmOriginal.MapEntityValue(_entityType, item, ov.Value);
// ov.Time = DateTime.Now;
// return ov;
// });
// }
//}
///// <summary>
///// 完成编辑数据,进行保存动作<para></para>
///// 该方法根据 BeginEdit 传入的状态分析出添加、修改、删除 SQL 语句
///// </summary>
///// <returns></returns>
//public int EndEdit()
//{
// var beforeAffrows = 0;
// if (_dataEditing == null) return 0;
// var oldEnable = _db.Options.EnableAddOrUpdateNavigateList;
// _db.Options.EnableAddOrUpdateNavigateList = false;
// try
// {
// DbContextFlushCommand();
// var addList = new List<TEntity>();
// var ediList = new List<TEntity>();
// foreach (var item in _dataEditing)
// {
// var key = _db.OrmOriginal.GetEntityKeyString(_entityType, item, false);
// if (_statesEditing.TryRemove(key, out var state) == false)
// {
// addList.Add(item);
// continue;
// }
// _states.AddOrUpdate(key, k => state, (k, ov) =>
// {
// ov.Value = state.Value;
// ov.Time = DateTime.Now;
// return ov;
// });
// if (_db.OrmOriginal.CompareEntityValueReturnColumns(_entityType, item, state.Value, false).Any())
// ediList.Add(item);
// }
// beforeAffrows = _db._affrows;
// AddRange(addList);
// UpdateRange(ediList);

// DbContextFlushCommand();
// var delList = _statesEditing.Values.OrderBy(a => a.Time).ToArray();
// _db._affrows += DbContextBatchRemove(delList); //为了减的少不必要的开销,此处没有直接调用 RemoveRange
// foreach (var state in delList)
// {
// _db.OrmOriginal.ClearEntityPrimaryValueWithIdentityAndGuid(_entityType, state.Value);
// _states.TryRemove(state.Key, out var oldstate);
// }
// DbContextFlushCommand();
// }
// finally
// {
// _dataEditing = null;
// _statesEditing.Clear();
// _db.Options.EnableAddOrUpdateNavigateList = oldEnable;
// }
// return _db._affrows - beforeAffrows;
//}
#endregion
}
}
2 changes: 1 addition & 1 deletion FreeSql.DbContext/FreeSql.DbContext.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp31;netcoreapp30;netcoreapp22;netcoreapp21;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql is the ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, Odbc, 达梦, 人大金仓, 神舟通用, And Access</Description>
Expand Down
16 changes: 16 additions & 0 deletions FreeSql.DbContext/FreeSql.DbContext.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FreeSql.Repository/FreeSql.Repository.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp31;netcoreapp30;netcoreapp22;netcoreapp21;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite/达梦/人大金仓/神舟通用/Access, and read/write separation、and split table.</Description>
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
Expand Down
15 changes: 15 additions & 0 deletions FreeSql.Tests/FreeSql.Tests.DbContext/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public void Include_ManyToMany()

using (var ctx = g.sqlite.CreateDbContext())
{
//var setTag = ctx.Set<Tag>();
//var tags = setTag.Select.Limit(10).ToList();
//setTag.BeginEdit(tags);

//tags.Add(new Tag
//{
// Ddd = DateTime.Now.Second,
// Name = "test_manytoMany_01_中国2234234"
//});
//tags[0].Name = "123123";
//tags.RemoveAt(1);

//tags.Clear();

//Assert.Equal(10, setTag.EndEdit());

var test150_02 = ctx.Set<Tag>()
.Select.From<Tag>((s, b) => s.InnerJoin(a => a.Id == b.Id))
Expand Down
8 changes: 4 additions & 4 deletions FreeSql/Extensions/FreeSqlGlobalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ public static List<T1> IncludeMany<T1, TNavigate>(this List<T1> list, IFreeSql o
{
var tb = orm.CodeFirst.GetTableByEntity(typeof(T1));
if (tb == null || tb.Primarys.Any() == false)
(orm.CodeFirst as FreeSql.Internal.CommonProvider.CodeFirstProvider)._dicSycedTryAdd(typeof(T1)); //._dicSyced.TryAdd(typeof(TReturn), true);
(orm.CodeFirst as CodeFirstProvider)._dicSycedTryAdd(typeof(T1)); //._dicSyced.TryAdd(typeof(TReturn), true);
}
var select = orm.Select<T1>().IncludeMany(navigateSelector, then) as FreeSql.Internal.CommonProvider.Select1Provider<T1>;
var select = orm.Select<T1>().IncludeMany(navigateSelector, then) as Select1Provider<T1>;
select.SetList(list);
return list;
}
Expand All @@ -322,9 +322,9 @@ async public static System.Threading.Tasks.Task<List<T1>> IncludeManyAsync<T1, T
{
var tb = orm.CodeFirst.GetTableByEntity(typeof(T1));
if (tb == null || tb.Primarys.Any() == false)
(orm.CodeFirst as FreeSql.Internal.CommonProvider.CodeFirstProvider)._dicSycedTryAdd(typeof(T1)); //._dicSyced.TryAdd(typeof(TReturn), true);
(orm.CodeFirst as CodeFirstProvider)._dicSycedTryAdd(typeof(T1)); //._dicSyced.TryAdd(typeof(TReturn), true);
}
var select = orm.Select<T1>().IncludeMany(navigateSelector, then) as FreeSql.Internal.CommonProvider.Select1Provider<T1>;
var select = orm.Select<T1>().IncludeMany(navigateSelector, then) as Select1Provider<T1>;
await select.SetListAsync(list);
return list;
}
Expand Down
2 changes: 1 addition & 1 deletion FreeSql/FreeSql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>ncc;YeXiangQin</Authors>
<Description>FreeSql is the ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, Odbc, 达梦, 人大金仓, 神舟通用, And Access</Description>
Expand Down
Loading

0 comments on commit f897aa0

Please sign in to comment.