mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
修正拼写错误的内部方法名
This commit is contained in:
parent
d67e9644eb
commit
54ceb537d9
@ -6,9 +6,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.0" />
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
|
||||||
<PackageReference Include="sqlSugarCore" Version="4.9.9.3" />
|
<PackageReference Include="sqlSugarCore" Version="5.0.0.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -17,7 +17,7 @@ namespace FreeSql
|
|||||||
return SaveChangesSuccess();
|
return SaveChangesSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Dictionary<Type, Dictionary<string, Func<object, object[], Task<int>>>> _dicExecCommandDbContextBetchAsync = new Dictionary<Type, Dictionary<string, Func<object, object[], Task<int>>>>();
|
static Dictionary<Type, Dictionary<string, Func<object, object[], Task<int>>>> _dicExecCommandDbContextBatchAsync = new Dictionary<Type, Dictionary<string, Func<object, object[], Task<int>>>>();
|
||||||
async internal Task ExecCommandAsync()
|
async internal Task ExecCommandAsync()
|
||||||
{
|
{
|
||||||
if (isExecCommanding) return;
|
if (isExecCommanding) return;
|
||||||
@ -27,9 +27,9 @@ namespace FreeSql
|
|||||||
ExecCommandInfo oldinfo = null;
|
ExecCommandInfo oldinfo = null;
|
||||||
var states = new List<object>();
|
var states = new List<object>();
|
||||||
|
|
||||||
Func<string, Task<int>> dbContextBetch = methodName =>
|
Func<string, Task<int>> dbContextBatch = methodName =>
|
||||||
{
|
{
|
||||||
if (_dicExecCommandDbContextBetchAsync.TryGetValue(oldinfo.stateType, out var trydic) == false)
|
if (_dicExecCommandDbContextBatchAsync.TryGetValue(oldinfo.stateType, out var trydic) == false)
|
||||||
trydic = new Dictionary<string, Func<object, object[], Task<int>>>();
|
trydic = new Dictionary<string, Func<object, object[], Task<int>>>();
|
||||||
if (trydic.TryGetValue(methodName, out var tryfunc) == false)
|
if (trydic.TryGetValue(methodName, out var tryfunc) == false)
|
||||||
{
|
{
|
||||||
@ -53,19 +53,19 @@ namespace FreeSql
|
|||||||
};
|
};
|
||||||
Func<Task> funcDelete = async () =>
|
Func<Task> funcDelete = async () =>
|
||||||
{
|
{
|
||||||
_affrows += await dbContextBetch("DbContextBetchRemoveAsync");
|
_affrows += await dbContextBatch("DbContextBatchRemoveAsync");
|
||||||
states.Clear();
|
states.Clear();
|
||||||
};
|
};
|
||||||
Func<Task> funcInsert = async () =>
|
Func<Task> funcInsert = async () =>
|
||||||
{
|
{
|
||||||
_affrows += await dbContextBetch("DbContextBetchAddAsync");
|
_affrows += await dbContextBatch("DbContextBatchAddAsync");
|
||||||
states.Clear();
|
states.Clear();
|
||||||
};
|
};
|
||||||
Func<bool, Task> funcUpdate = async (isLiveUpdate) =>
|
Func<bool, Task> funcUpdate = async (isLiveUpdate) =>
|
||||||
{
|
{
|
||||||
var affrows = 0;
|
var affrows = 0;
|
||||||
if (isLiveUpdate) affrows = await dbContextBetch("DbContextBetchUpdateNowAsync");
|
if (isLiveUpdate) affrows = await dbContextBatch("DbContextBatchUpdateNowAsync");
|
||||||
else affrows = await dbContextBetch("DbContextBetchUpdateAsync");
|
else affrows = await dbContextBatch("DbContextBatchUpdateAsync");
|
||||||
if (affrows == -999)
|
if (affrows == -999)
|
||||||
{ //最后一个元素已被删除
|
{ //最后一个元素已被删除
|
||||||
states.RemoveAt(states.Count - 1);
|
states.RemoveAt(states.Count - 1);
|
||||||
|
@ -30,7 +30,7 @@ namespace FreeSql
|
|||||||
return SaveChangesSuccess();
|
return SaveChangesSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Dictionary<Type, Dictionary<string, Func<object, object[], int>>> _dicExecCommandDbContextBetch = new Dictionary<Type, Dictionary<string, Func<object, object[], int>>>();
|
static Dictionary<Type, Dictionary<string, Func<object, object[], int>>> _dicExecCommandDbContextBatch = new Dictionary<Type, Dictionary<string, Func<object, object[], int>>>();
|
||||||
bool isExecCommanding = false;
|
bool isExecCommanding = false;
|
||||||
internal void ExecCommand()
|
internal void ExecCommand()
|
||||||
{
|
{
|
||||||
@ -41,9 +41,9 @@ namespace FreeSql
|
|||||||
ExecCommandInfo oldinfo = null;
|
ExecCommandInfo oldinfo = null;
|
||||||
var states = new List<object>();
|
var states = new List<object>();
|
||||||
|
|
||||||
Func<string, int> dbContextBetch = methodName =>
|
Func<string, int> dbContextBatch = methodName =>
|
||||||
{
|
{
|
||||||
if (_dicExecCommandDbContextBetch.TryGetValue(oldinfo.stateType, out var trydic) == false)
|
if (_dicExecCommandDbContextBatch.TryGetValue(oldinfo.stateType, out var trydic) == false)
|
||||||
trydic = new Dictionary<string, Func<object, object[], int>>();
|
trydic = new Dictionary<string, Func<object, object[], int>>();
|
||||||
if (trydic.TryGetValue(methodName, out var tryfunc) == false)
|
if (trydic.TryGetValue(methodName, out var tryfunc) == false)
|
||||||
{
|
{
|
||||||
@ -67,19 +67,19 @@ namespace FreeSql
|
|||||||
};
|
};
|
||||||
Action funcDelete = () =>
|
Action funcDelete = () =>
|
||||||
{
|
{
|
||||||
_affrows += dbContextBetch("DbContextBetchRemove");
|
_affrows += dbContextBatch("DbContextBatchRemove");
|
||||||
states.Clear();
|
states.Clear();
|
||||||
};
|
};
|
||||||
Action funcInsert = () =>
|
Action funcInsert = () =>
|
||||||
{
|
{
|
||||||
_affrows += dbContextBetch("DbContextBetchAdd");
|
_affrows += dbContextBatch("DbContextBatchAdd");
|
||||||
states.Clear();
|
states.Clear();
|
||||||
};
|
};
|
||||||
Action<bool> funcUpdate = isLiveUpdate =>
|
Action<bool> funcUpdate = isLiveUpdate =>
|
||||||
{
|
{
|
||||||
var affrows = 0;
|
var affrows = 0;
|
||||||
if (isLiveUpdate) affrows = dbContextBetch("DbContextBetchUpdateNow");
|
if (isLiveUpdate) affrows = dbContextBatch("DbContextBatchUpdateNow");
|
||||||
else affrows = dbContextBetch("DbContextBetchUpdate");
|
else affrows = dbContextBatch("DbContextBatchUpdate");
|
||||||
if (affrows == -999)
|
if (affrows == -999)
|
||||||
{ //最后一个元素已被删除
|
{ //最后一个元素已被删除
|
||||||
states.RemoveAt(states.Count - 1);
|
states.RemoveAt(states.Count - 1);
|
||||||
|
@ -20,7 +20,7 @@ namespace FreeSql
|
|||||||
return _db.ExecCommandAsync();
|
return _db.ExecCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<int> DbContextBetchAddAsync(EntityState[] adds)
|
async Task<int> DbContextBatchAddAsync(EntityState[] adds)
|
||||||
{
|
{
|
||||||
if (adds.Any() == false) return 0;
|
if (adds.Any() == false) return 0;
|
||||||
var affrows = await this.OrmInsert(adds.Select(a => a.Value)).ExecuteAffrowsAsync();
|
var affrows = await this.OrmInsert(adds.Select(a => a.Value)).ExecuteAffrowsAsync();
|
||||||
@ -303,9 +303,9 @@ namespace FreeSql
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UpdateAsync
|
#region UpdateAsync
|
||||||
Task<int> DbContextBetchUpdateAsync(EntityState[] ups) => DbContextBetchUpdatePrivAsync(ups, false);
|
Task<int> DbContextBatchUpdateAsync(EntityState[] ups) => DbContextBatchUpdatePrivAsync(ups, false);
|
||||||
Task<int> DbContextBetchUpdateNowAsync(EntityState[] ups) => DbContextBetchUpdatePrivAsync(ups, true);
|
Task<int> DbContextBatchUpdateNowAsync(EntityState[] ups) => DbContextBatchUpdatePrivAsync(ups, true);
|
||||||
async Task<int> DbContextBetchUpdatePrivAsync(EntityState[] ups, bool isLiveUpdate)
|
async Task<int> DbContextBatchUpdatePrivAsync(EntityState[] ups, bool isLiveUpdate)
|
||||||
{
|
{
|
||||||
if (ups.Any() == false) return 0;
|
if (ups.Any() == false) return 0;
|
||||||
var uplst1 = ups[ups.Length - 1];
|
var uplst1 = ups[ups.Length - 1];
|
||||||
@ -392,7 +392,7 @@ namespace FreeSql
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region RemoveAsync
|
#region RemoveAsync
|
||||||
async Task<int> DbContextBetchRemoveAsync(EntityState[] dels)
|
async Task<int> DbContextBatchRemoveAsync(EntityState[] dels)
|
||||||
{
|
{
|
||||||
if (dels.Any() == false) return 0;
|
if (dels.Any() == false) return 0;
|
||||||
var affrows = await this.OrmDelete(dels.Select(a => a.Value)).ExecuteAffrowsAsync();
|
var affrows = await this.OrmDelete(dels.Select(a => a.Value)).ExecuteAffrowsAsync();
|
||||||
|
@ -19,7 +19,7 @@ namespace FreeSql
|
|||||||
_db.ExecCommand();
|
_db.ExecCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DbContextBetchAdd(EntityState[] adds)
|
int DbContextBatchAdd(EntityState[] adds)
|
||||||
{
|
{
|
||||||
if (adds.Any() == false) return 0;
|
if (adds.Any() == false) return 0;
|
||||||
var affrows = this.OrmInsert(adds.Select(a => a.Value)).ExecuteAffrows();
|
var affrows = this.OrmInsert(adds.Select(a => a.Value)).ExecuteAffrows();
|
||||||
@ -338,9 +338,9 @@ namespace FreeSql
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
int DbContextBetchUpdate(EntityState[] ups) => DbContextBetchUpdatePriv(ups, false);
|
int DbContextBatchUpdate(EntityState[] ups) => DbContextBatchUpdatePriv(ups, false);
|
||||||
int DbContextBetchUpdateNow(EntityState[] ups) => DbContextBetchUpdatePriv(ups, true);
|
int DbContextBatchUpdateNow(EntityState[] ups) => DbContextBatchUpdatePriv(ups, true);
|
||||||
int DbContextBetchUpdatePriv(EntityState[] ups, bool isLiveUpdate)
|
int DbContextBatchUpdatePriv(EntityState[] ups, bool isLiveUpdate)
|
||||||
{
|
{
|
||||||
if (ups.Any() == false) return 0;
|
if (ups.Any() == false) return 0;
|
||||||
var uplst1 = ups[ups.Length - 1];
|
var uplst1 = ups[ups.Length - 1];
|
||||||
@ -433,7 +433,7 @@ namespace FreeSql
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Remove
|
#region Remove
|
||||||
int DbContextBetchRemove(EntityState[] dels)
|
int DbContextBatchRemove(EntityState[] dels)
|
||||||
{
|
{
|
||||||
if (dels.Any() == false) return 0;
|
if (dels.Any() == false) return 0;
|
||||||
var affrows = this.OrmDelete(dels.Select(a => a.Value)).ExecuteAffrows();
|
var affrows = this.OrmDelete(dels.Select(a => a.Value)).ExecuteAffrows();
|
||||||
|
@ -110,13 +110,6 @@
|
|||||||
清空状态数据
|
清空状态数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
|
||||||
<summary>
|
|
||||||
根据 lambda 条件删除数据
|
|
||||||
</summary>
|
|
||||||
<param name="predicate"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
|
@ -103,19 +103,19 @@ namespace FreeSql.Tests.SqlServer
|
|||||||
//items = Enumerable.Range(0, 9989).Select(a => new Topic { Title = "newtitle" + a, CreateTime = DateTime.Now }).ToList();
|
//items = Enumerable.Range(0, 9989).Select(a => new Topic { Title = "newtitle" + a, CreateTime = DateTime.Now }).ToList();
|
||||||
//Assert.Equal(9989, g.sqlserver.Insert<Topic>(items).ExecuteAffrows());
|
//Assert.Equal(9989, g.sqlserver.Insert<Topic>(items).ExecuteAffrows());
|
||||||
|
|
||||||
//var bttype = new TestBetchInsertType { title = "testbttitle1" };
|
//var bttype = new TestBatchInsertType { title = "testbttitle1" };
|
||||||
//bttype.id = (int)g.sqlserver.Insert(bttype).ExecuteIdentity();
|
//bttype.id = (int)g.sqlserver.Insert(bttype).ExecuteIdentity();
|
||||||
//Assert.True(bttype.id > 0);
|
//Assert.True(bttype.id > 0);
|
||||||
//var bttopic = Enumerable.Range(0, 10000).Select(a => new TestBetchInsertTopic { TypeId = bttype.id, Text = $"testtopic{a}" }).ToArray();
|
//var bttopic = Enumerable.Range(0, 10000).Select(a => new TestBatchInsertTopic { TypeId = bttype.id, Text = $"testtopic{a}" }).ToArray();
|
||||||
//Assert.Equal(bttopic.Length, g.sqlserver.Insert<TestBetchInsertTopic>(bttopic).ExecuteAffrows());
|
//Assert.Equal(bttopic.Length, g.sqlserver.Insert<TestBatchInsertTopic>(bttopic).ExecuteAffrows());
|
||||||
|
|
||||||
//g.sqlserver.Transaction(() =>
|
//g.sqlserver.Transaction(() =>
|
||||||
//{
|
//{
|
||||||
// bttype = new TestBetchInsertType { title = "transaction_testbttitle2" };
|
// bttype = new TestBatchInsertType { title = "transaction_testbttitle2" };
|
||||||
// bttype.id = (int)g.sqlserver.Insert(bttype).ExecuteIdentity();
|
// bttype.id = (int)g.sqlserver.Insert(bttype).ExecuteIdentity();
|
||||||
// Assert.True(bttype.id > 0);
|
// Assert.True(bttype.id > 0);
|
||||||
// bttopic = Enumerable.Range(0, 10000).Select(a => new TestBetchInsertTopic { TypeId = bttype.id, Text = $"transaction_testtopic{a}" }).ToArray();
|
// bttopic = Enumerable.Range(0, 10000).Select(a => new TestBatchInsertTopic { TypeId = bttype.id, Text = $"transaction_testtopic{a}" }).ToArray();
|
||||||
// Assert.Equal(bttopic.Length, g.sqlserver.Insert<TestBetchInsertTopic>(bttopic).ExecuteAffrows());
|
// Assert.Equal(bttopic.Length, g.sqlserver.Insert<TestBatchInsertTopic>(bttopic).ExecuteAffrows());
|
||||||
//});
|
//});
|
||||||
|
|
||||||
g.sqlserver.Transaction(() =>
|
g.sqlserver.Transaction(() =>
|
||||||
@ -127,12 +127,12 @@ namespace FreeSql.Tests.SqlServer
|
|||||||
Assert.Equal(detail.Length, g.sqlserver.Insert<AdjustPriceDetail>(detail).NoneParameter().ExecuteAffrows());
|
Assert.Equal(detail.Length, g.sqlserver.Insert<AdjustPriceDetail>(detail).NoneParameter().ExecuteAffrows());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
class TestBetchInsertType {
|
class TestBatchInsertType {
|
||||||
[Column(IsIdentity = true)]
|
[Column(IsIdentity = true)]
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
}
|
}
|
||||||
class TestBetchInsertTopic
|
class TestBatchInsertTopic
|
||||||
{
|
{
|
||||||
public Guid id { get; set; }
|
public Guid id { get; set; }
|
||||||
public int TypeId { get; set; }
|
public int TypeId { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user