我正在学习 linq to sql。
是否可以在 linq to sql 中编写以下条件?
条件一
var query1 =
if
from q in db.Students
q.fees =="paid" && q.activites == "good" && count == 0
select q
save "OK" to the property result.
else
from q in db.Students
q.fees =="paid" && q.activites == "good" && count == 2
select q
save "better" to the property result.
else
from q in db.Students
q.fees =="paid" && q.activites == "good" && count > 2
select q
save "bad" to the property result.
private string _result;
public string Result
{
get { return this._result; ; }
set { this._result; = value; }
}
请指导。
更新编辑:
var query1 =
(from q in db.Students
q.fees =="paid" && q.activites == "good"
select q).Any();
if(count ==0 && query1 == true)
{
this.Result = "OK"
}
esle if(count == 2 && query1 == true)
{
this.Result = "better"
}
esle
{
this.Result = "bad"
}
这将是一种方法吗?