【发布时间】:2013-05-21 08:20:49
【问题描述】:
我有一个非常奇怪的问题。
我有这个问题:
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 个项目吗?
【问题讨论】:
-
哪个是正确的?
-
@FrancescoDeLisi
SQL结果。 -
我在模型主键设置不正确时遇到了这个问题,请先检查。
-
你能列出coreEntityModel.SystemAppEntityViewModelFieldCustom_SecurityByUser的值吗?看起来很奇怪。
-
也许你需要刷新你的上下文?
标签: c# .net sql linq entity-framework