我有一个很奇怪的问题。

我有这个查询:

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和2。

知道为什么LINQ会产生“ CustomFilterID” = 1的所有4个项目吗?

最佳答案

找到了问题。我的View没有选择表的PK列,而是通过将表的PK列添加到View的选择列表中,它产生了正确的结果。

09-26 18:11