Skip to content

Commit 91362ad

Browse files
committed
- 修复 WithMemory 对 InsertValueSql 属性无效的问题;
1 parent 49c8996 commit 91362ad

File tree

5 files changed

+118
-103
lines changed

5 files changed

+118
-103
lines changed

Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootRepository.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ public void FlushState()
119119
public ISelect<TEntity> WhereIf(bool condition, Expression<Func<TEntity, bool>> exp) => Select.WhereIf(condition, exp);
120120

121121
readonly Dictionary<Type, IBaseRepository<object>> _childRepositorys = new Dictionary<Type, IBaseRepository<object>>();
122+
protected virtual IFreeSql GetChildFreeSql(Type type) => Orm;
122123
IBaseRepository<object> GetChildRepository(Type type)
123124
{
124125
if (_childRepositorys.TryGetValue(type, out var repo) == false)
125126
{
126-
repo = Orm.GetRepository<object>();
127+
repo = GetChildFreeSql(type).GetRepository<object>();
127128
repo.AsType(type);
128129
_childRepositorys.Add(type, repo);
129130
}

Extensions/FreeSql.Extensions.AggregateRoot/FreeSql.Extensions.AggregateRoot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<SignAssembly>true</SignAssembly>
1919
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
2020
<DelaySign>false</DelaySign>
21-
<Version>3.2.812</Version>
21+
<Version>3.2.813-preview20240205</Version>
2222
<PackageReadmeFile>readme.md</PackageReadmeFile>
2323
</PropertyGroup>
2424

FreeSql/FreeSql.xml

Lines changed: 112 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public IInsertOrUpdate<T1> AsType(Type entityType)
264264
return this;
265265
}
266266

267-
public void WriteSourceSelectUnionAll(List<T1> source, StringBuilder sb, List<DbParameter> dbParams)
267+
public void WriteSourceSelectUnionAll(List<T1> source, StringBuilder sb, List<DbParameter> dbParams, bool disableInsertValueSql = false)
268268
{
269269
if (_sourceSql != null)
270270
{
@@ -287,7 +287,7 @@ public void WriteSourceSelectUnionAll(List<T1> source, StringBuilder sb, List<Db
287287
foreach (var col in _table.Columns.Values)
288288
{
289289
if (colidx2 > 0) sb.Append(", ");
290-
if (string.IsNullOrEmpty(col.DbInsertValue) == false)
290+
if (disableInsertValueSql == false && string.IsNullOrEmpty(col.DbInsertValue) == false)
291291
sb.Append(col.DbInsertValue);
292292
else
293293
{

FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public ISelect<T1> WithMemory(IEnumerable<T1> source)
529529
if (list.Any() != true) throw new Exception(CoreStrings.Cannot_Be_NULL_Name(nameof(source)));
530530
var sb = new StringBuilder();
531531
(_orm.InsertOrUpdate<object>().AsType(_tables[0].Table.Type) as InsertOrUpdateProvider<object>)
532-
.WriteSourceSelectUnionAll(list, sb, _params);
532+
.WriteSourceSelectUnionAll(list, sb, _params, true);
533533

534534
try { return WithSql(sb.ToString()); }
535535
finally { sb.Clear(); }

0 commit comments

Comments
 (0)