- 补充 WithMemory null/Empty 参数判断;

This commit is contained in:
2881099 2023-12-28 13:56:14 +08:00
parent ebd9cbed0f
commit 2272c46df6

View File

@ -525,9 +525,11 @@ namespace FreeSql.Internal.CommonProvider
} }
public ISelect<T1> WithMemory(IEnumerable<T1> source) public ISelect<T1> WithMemory(IEnumerable<T1> source)
{ {
var list = source?.Select(a => (object)a).ToList();
if (list.Any() != true) throw new Exception(CoreStrings.Cannot_Be_NULL_Name(nameof(source)));
var sb = new StringBuilder(); var sb = new StringBuilder();
(_orm.InsertOrUpdate<object>().AsType(_tables[0].Table.Type) as InsertOrUpdateProvider<object>) (_orm.InsertOrUpdate<object>().AsType(_tables[0].Table.Type) as InsertOrUpdateProvider<object>)
.WriteSourceSelectUnionAll(source.Select(a => (object)a).ToList(), sb, _params); .WriteSourceSelectUnionAll(list, sb, _params);
try { return WithSql(sb.ToString()); } try { return WithSql(sb.ToString()); }
finally { sb.Clear(); } finally { sb.Clear(); }