mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 修复 Repository/DbContext 批量修改可能无效的 bug;#709
This commit is contained in:
parent
2b982ff350
commit
092bbe47dd
@ -133,7 +133,11 @@ namespace FreeSql
|
||||
if (isLiveUpdate || oldinfo.changeType == EntityChangeType.Update)
|
||||
{
|
||||
if (states.Any())
|
||||
{
|
||||
await funcUpdate(isLiveUpdate);
|
||||
if (info?.changeType == EntityChangeType.Update)
|
||||
flagFuncUpdateLaststate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (info != null)
|
||||
|
@ -148,7 +148,11 @@ namespace FreeSql
|
||||
if (isLiveUpdate || oldinfo.changeType == EntityChangeType.Update)
|
||||
{
|
||||
if (states.Any())
|
||||
{
|
||||
funcUpdate(isLiveUpdate);
|
||||
if (info?.changeType == EntityChangeType.Update)
|
||||
flagFuncUpdateLaststate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (info != null)
|
||||
|
@ -2,12 +2,34 @@ using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests
|
||||
{
|
||||
public class RepositoryTests
|
||||
{
|
||||
/// <summary>
|
||||
/// ¸üÒ»ÌõÎÞ·¨¸üС£
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Fact]
|
||||
public async Task Updatemysql()
|
||||
{
|
||||
var item1 = new AddUpdateInfo();
|
||||
g.mysql.Insert(item1).ExecuteAffrows();
|
||||
var item2 = new AddUpdateInfo();
|
||||
g.mysql.Insert(item2).ExecuteAffrows();
|
||||
var item3 = new AddUpdateInfo();
|
||||
g.mysql.Insert(item3).ExecuteAffrows();
|
||||
|
||||
var repos = g.mysql.GetGuidRepository<AddUpdateInfo>();
|
||||
var items = repos.Select.WhereDynamic(new[] { item1, item2, item3 }).ToList();
|
||||
items[0].Title = "88";
|
||||
//items[1].Title = "88";
|
||||
items[2].Title = "88";
|
||||
int x = await repos.UpdateAsync(items);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddUpdate()
|
||||
|
@ -171,6 +171,8 @@ namespace FreeSql.Tests.PostgreSQLExpression
|
||||
var sql16 = select.Where(a => a.testFieldJArray.Count() > 0).Limit(10).ToList();
|
||||
var sql17 = select.Where(a => a.testFieldJArray.LongCount() > 0).Limit(10).ToList();
|
||||
var sql18 = select.Where(a => a.testFieldJArray.Count > 0).Limit(10).ToList();
|
||||
|
||||
var sql19 = select.First(a => a.testFieldJToken["a"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -174,6 +174,26 @@ namespace FreeSql
|
||||
/// <returns></returns>
|
||||
public static ICaseWhenEnd Case() => SqlExtExtensions.Case();
|
||||
/// <summary>
|
||||
/// case when .. then .. end
|
||||
/// </summary>
|
||||
/// <typeparam name="TInput"></typeparam>
|
||||
/// <typeparam name="TOutput"></typeparam>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="dict"></param>
|
||||
/// <returns></returns>
|
||||
public static TOutput CaseDict<TInput, TOutput>(TInput input, [RawValue] Dictionary<TInput, TOutput> dict)
|
||||
{
|
||||
var ec = expContext.Value;
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("case");
|
||||
foreach (var kv in dict)
|
||||
sb.Append(" when ").Append(ec.ParsedContent["input"]).Append(" = ").Append(ec.FormatSql(kv.Key))
|
||||
.Append(" then ").Append(ec.FormatSql(kv.Value));
|
||||
sb.Append(" end");
|
||||
ec.Result = sb.ToString();
|
||||
return default;
|
||||
}
|
||||
/// <summary>
|
||||
/// MySql group_concat(distinct .. order by .. separator ..)
|
||||
/// </summary>
|
||||
/// <param name="column"></param>
|
||||
|
@ -1232,6 +1232,16 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.SqlExt.CaseDict``2(``0,System.Collections.Generic.Dictionary{``0,``1})">
|
||||
<summary>
|
||||
case when .. then .. end
|
||||
</summary>
|
||||
<typeparam name="TInput"></typeparam>
|
||||
<typeparam name="TOutput"></typeparam>
|
||||
<param name="input"></param>
|
||||
<param name="dict"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.SqlExt.GroupConcat(System.Object)">
|
||||
<summary>
|
||||
MySql group_concat(distinct .. order by .. separator ..)
|
||||
|
@ -424,7 +424,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
|
||||
dropSequence(seqname);
|
||||
if (seqcol.Item3)
|
||||
{
|
||||
var startWith = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from all_tab_columns where owner={0} and table_name={1} and column_name={2}", tbname[0], tbname[1], colname2)) == null ? 1 :
|
||||
var startWith = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(" select 1 from all_tab_columns where owner={0} and table_name={1} and column_name={2}", tbname[0], tbname[1], seqcol.Item1.Attribute.Name)) == null ? 1 :
|
||||
_orm.Ado.ExecuteScalar(CommandType.Text, $" select nvl(max({colname2})+1,1) from {tbname2}");
|
||||
sb.Append("execute immediate 'CREATE SEQUENCE ").Append(_commonUtils.QuoteSqlName(seqname)).Append(" start with ").Append(startWith).Append("';\r\n");
|
||||
sb.Append("execute immediate 'CREATE OR REPLACE TRIGGER ").Append(_commonUtils.QuoteSqlName(tiggerName))
|
||||
|
Loading…
x
Reference in New Issue
Block a user