【发布时间】:2010-05-21 21:03:35
【问题描述】:
基本上我想在我的 linq to sql 语句中有一个 if-else 语句。
var query = from d in database
if(x == y) {
where d.Attr = x
}
else {
where d.Attr = y
}
select d;
有什么想法吗?
【问题讨论】:
-
我猜这只是一个示例,您实际上并没有使用该检查,因为如果您使用,它将始终解决“y”值的情况。 x=4, y=3 使用 else (3) x=3, y=3 使用 if (3)
标签: c# asp.net-mvc linq-to-sql where-clause