我想在Linq中的一个查询中查询sql where Condition And和Or。我尝试在下面编写代码,但没有工作。我想在CEvaUserEva或EEvaUserEva或OEvaUserEva中查询where ID,但状态必须为“成功”请帮助我。
public ActionResult Get(string id)
{
try
{
var result = (
from pre in context.PreChanges
join cus in context.PreEvaCustomers on pre.DocNumber equals cus.CDocNumber
join env in context.PreEvaEnvis on pre.DocNumber equals env.EDocNumber
join oth in context.PreEvaOthers on pre.DocNumber equals oth.ODocNumber
join sta in context.StatusDocs on pre.DocNumber equals sta.SDocNumber
select new GetAll
{
DocNumber = pre.DocNumber,
Users = pre.Users,
UserId = pre.UserId,
CDocNumber = cus.CDocNumber,
CEvaUserEva = cus.CEvaUserEva,
EDocNumber = env.EDocNumber,
EEvaUserEva = env.EEvaUserEva,
ODocNumber = cus.CDocNumber,
OEvaUserEva = oth.OEvaUserEva,
SDocNumber = sta.SDocNumber,
StatusDoc =sta.StatusDoc
})
.Where((g => g.CEvaUserEva == id || g.EEvaUserEva == id ||
g.OEvaUserEva == id && (g => g.StatusDoc== "Success"));
return Ok(result);
}
catch (Exception ex)
{
return BadRequest(ex.Message + "GetC 47");
}
}
1条答案
按热度按时间2w2cym1i1#
您需要在或区块前后加上括号