gpt4 book ai didi

entity-framework - 如何在 Entity Framework 中使用linq在where条件下使用 "not equal to"

转载 作者:行者123 更新时间:2023-12-05 08:54:25 28 4
gpt4 key购买 nike

如何使用带有 Entity Framework 的 LINQ 在 where 条件下使用“不等于”。

public ActionResult ViewOfficeType()
{
return View(entity.TBL_OFFICETYPE.Where(p => p.STATUS<>"D").ToList());
}

it shows invalid expression '>'

如果我使用 '!='。它不会显示错误。但它不起作用。

最佳答案

您可以在 Equals() 上使用 ! 运算符

public ActionResult ViewOfficeType()
{
return View(entity.TBL_OFFICETYPE.Where(p => !p.Equals("D")).ToList());
}

关于entity-framework - 如何在 Entity Framework 中使用linq在where条件下使用 "not equal to",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50128116/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com