我有一个非常奇怪的问题。
我有这个查询:
var systemAppEntityViewModelFieldCustom_SecurityByUserList = (from t in coreEntityModel.SystemAppEntityViewModelFieldCustom_SecurityByUser
where (t.SystemAppUserID == CurrentSystemAppUser.SystemAppUserID)
&& (t.SystemCultureID == CurrentSystemAppUser.SystemCultureID)
select t).ToList();
为“CustomFilterID”字段生成这些值:
如您所见,所有 4 个项目的“CustomFilterID”= 1,但是当我检查 SQLProfiler 并在 SQLServer 中运行结果查询时,我得到以下结果:
“CustomFilterID”的变体 = 1 AND 2。
知道为什么 LINQ 会生成“CustomFilterID”= 1 的所有 4 个项目吗?
最佳答案
发现问题了。我的 View
没有选择表的 PK
列,也没有将表的 PK
列添加到 的选择列表中查看
,它产生了正确的结果。
关于c# - LINQ - 不返回与 SQL Server 相同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16665253/