有人可以帮我解决这个例外吗?我不明白它意味着什么或如何解决它…这是一个sqlException,带有以下消息:
All queries combined using a UNION,INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
// Some filtering of data var query = data.Subjects .Where(has value) .Where(has other value among some set of values); // More filtering,where I need to have two different options var a = query .Where(some foreign key is null); var b = query .Where(some foreign key is not null) .Where(and that foreign key has a property which is what I want); query = a.Union(b); // Final filter and then get result as a list var list = query .Where(last requirement) .ToList();
如果我删除了a.Union(b)部分,它会毫无例外地运行.所以我知道错误就在那里.但为什么我会得到它?我该如何解决?我在这里做的事太疯狂吗?我误解了如何使用联盟的东西吗?
基本上我所拥有的是一些具有其他实体的外键的实体.我需要将所有将该外键设置为null的实体或该外来实体满足某些要求的实体.