How to test a lamda expression var query result is null?
- by mike
var query = from emp in dbEmp.Employees
join dept in dbEmp.Departments
on emp.DeptID equals dept.DeptID
where dept.DepartmentName.Contains(this.TextBox1.Text)
select new
{
EmpID = emp.EmpID,
EmpName = emp.EmpName,
Age = emp.Age,
Address = emp.Address,
DeptName = dept.DepartmentName
};
if (query==null)
Label1.Text = "no results match your search";
GridView1.DataSource = query;
GridView1.DataBind();
Everything works in the right way, but the label doesn't show the message when query result returns null. The label can show without condition(querry==null). So how to test if a var query result returns nothing? Thanks