From 2272c46df6b74436e6e873acc62f9f9ae71a09c9 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Thu, 28 Dec 2023 13:56:14 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E8=A1=A5=E5=85=85=20WithMemory=20null/Empt?= =?UTF-8?q?y=20=E5=8F=82=E6=95=B0=E5=88=A4=E6=96=AD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommonProvider/SelectProvider/Select1Provider.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs index 1e15f1a52..753de9030 100644 --- a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs +++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs @@ -525,9 +525,11 @@ public ISelect WithSql(string sql, object parms = null) } public ISelect WithMemory(IEnumerable source) { - var sb = new StringBuilder(); + 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(); (_orm.InsertOrUpdate().AsType(_tables[0].Table.Type) as InsertOrUpdateProvider) - .WriteSourceSelectUnionAll(source.Select(a => (object)a).ToList(), sb, _params); + .WriteSourceSelectUnionAll(list, sb, _params); try { return WithSql(sb.ToString()); } finally { sb.Clear(); }