HMJING
**过程虽可贵,结果价更高**

http://blog.csdn.net/q107770540/article/details/5724013

 

public string GetStudata()
{
string name = Request.QueryString["name"];
string sex = Request.QueryString["sex"];
string qurstr = "";
var stus = from p in data.Student
select p;
if (!string.IsNullOrEmpty(name) && sex != "Choose..." && sex != null)
{
stus = stus.Where(q=>q.name.Contains(name)&&q.sex==sex);
}
if (string.IsNullOrEmpty(name) && sex != "Choose..." && sex != null)
{
stus = stus.Where(q => q.sex == sex);
}
if (!string.IsNullOrEmpty(name) && sex == "Choose..." && sex!=null)
{
stus = stus.Where(q => q.name.Contains(name));
}

 

posted on 2016-02-25 16:55  HMJING  阅读(8332)  评论(0编辑  收藏  举报