Skip to content

Commit 34ba9fb

Browse files
2881028810
authored andcommitted
- 优化 Include 友好错误提示;
1 parent a45cfff commit 34ba9fb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ public ISelect<T1> Include<TNavigate>(Expression<Func<T1, TNavigate>> navigateSe
354354
{
355355
var expBody = navigateSelector?.Body;
356356
if (expBody == null) return this;
357+
if (expBody.NodeType != ExpressionType.MemberAccess) throw new Exception("Include 参数类型错误,表达式类型应该为 MemberAccess");
358+
if (typeof(IEnumerable).IsAssignableFrom(expBody.Type)) throw new Exception("Include 参数类型错误,集合属性请使用 IncludeMany");
357359
var tb = _commonUtils.GetTableByEntity(expBody.Type);
358360
if (tb == null) throw new Exception("Include 参数类型错误");
359361

0 commit comments

Comments
 (0)