[英]LINQ expression works good in LINQPad, but in Silverlight return empty result
[英]LINQ to return empty result
我想編寫一個 LINQ 來始終返回空列表。 我可以在 SQL 中做到這一點
SELECT * FROM EMPLOYEES WHERE 1=2
如何在 LINQ 中做到這一點?
我的確切情況是
private IQueryable <EMPLOYEE> getEmployee()
{
IQueryable <EMPLOYEE> employees;
//code
if(condition)
{
return employees
}
else
{
//here I want to return a empty result.
}
}
無需點擊數據庫。 您可以使用以下內容:
private IQueryable <EMPLOYEE> getEmployee()
{
return Enumerable.Empty<EMPLOYEE>().AsQueryable();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.