- 优化 无主键使用 IUpdate.SetSource 的错误提示;

This commit is contained in:
28810
2020-08-12 04:11:22 +08:00
parent 0d832a5a23
commit 882e671eee
5 changed files with 34 additions and 155 deletions

View File

@ -750,7 +750,10 @@ namespace FreeSql.Internal.CommonProvider
sb.Append(" \r\nWHERE ");
if (_source.Any())
{
if (_table.Primarys.Any() == false) throw new ArgumentException($"{_table.Type.DisplayCsharp()} 没有定义主键,无法使用 SetSource请尝试 SetDto");
sb.Append("(").Append(_commonUtils.WhereItems(_table, "", _source)).Append(")");
}
if (_where.Length > 0)
sb.Append(_source.Any() ? _where.ToString() : _where.ToString().Substring(5));