Skip to content

Commit

Permalink
- 修复 WithMemory 对 InsertValueSql 属性无效的问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Feb 5, 2024
1 parent 49c8996 commit 91362ad
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ public void FlushState()
public ISelect<TEntity> WhereIf(bool condition, Expression<Func<TEntity, bool>> exp) => Select.WhereIf(condition, exp);

readonly Dictionary<Type, IBaseRepository<object>> _childRepositorys = new Dictionary<Type, IBaseRepository<object>>();
protected virtual IFreeSql GetChildFreeSql(Type type) => Orm;
IBaseRepository<object> GetChildRepository(Type type)
{
if (_childRepositorys.TryGetValue(type, out var repo) == false)
{
repo = Orm.GetRepository<object>();
repo = GetChildFreeSql(type).GetRepository<object>();
repo.AsType(type);
_childRepositorys.Add(type, repo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812</Version>
<Version>3.2.813-preview20240205</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
210 changes: 112 additions & 98 deletions FreeSql/FreeSql.xml

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

4 changes: 2 additions & 2 deletions FreeSql/Internal/CommonProvider/InsertOrUpdateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public IInsertOrUpdate<T1> AsType(Type entityType)
return this;
}

public void WriteSourceSelectUnionAll(List<T1> source, StringBuilder sb, List<DbParameter> dbParams)
public void WriteSourceSelectUnionAll(List<T1> source, StringBuilder sb, List<DbParameter> dbParams, bool disableInsertValueSql = false)
{
if (_sourceSql != null)
{
Expand All @@ -287,7 +287,7 @@ public void WriteSourceSelectUnionAll(List<T1> source, StringBuilder sb, List<Db
foreach (var col in _table.Columns.Values)
{
if (colidx2 > 0) sb.Append(", ");
if (string.IsNullOrEmpty(col.DbInsertValue) == false)
if (disableInsertValueSql == false && string.IsNullOrEmpty(col.DbInsertValue) == false)
sb.Append(col.DbInsertValue);
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public ISelect<T1> WithMemory(IEnumerable<T1> source)
if (list.Any() != true) throw new Exception(CoreStrings.Cannot_Be_NULL_Name(nameof(source)));
var sb = new StringBuilder();
(_orm.InsertOrUpdate<object>().AsType(_tables[0].Table.Type) as InsertOrUpdateProvider<object>)
.WriteSourceSelectUnionAll(list, sb, _params);
.WriteSourceSelectUnionAll(list, sb, _params, true);

try { return WithSql(sb.ToString()); }
finally { sb.Clear(); }
Expand Down

0 comments on commit 91362ad

Please sign in to comment.