选择后如何检查LinqDataSource是否为空?

时间:2016-08-15 13:53:02

标签: c# asp.net is-empty linqdatasource

我有一个asp.NET应用程序,我使用LinqDataSource控件来填充ListView控件。这是我的LinqDataSource控件的OnSelecting命令的代码:

protected void lds_Selecting(object sender, LinqDataSourceSelectEvenArgs e)
{
    var db = new Models.EF.Entities();
    e.Result = from x in db.Sliders
                where x.IsPublic == true
                select x;
}

这很好但现在我想在结果为空的情况下运行if语句。如何查看结果是否为空?

1 个答案:

答案 0 :(得分:1)

使用let resultController = mainStoryboard.instantiateViewControllerWithIdentifier("SearchTableViewController") as! UITableViewController self.searchController = UISearchController(searchResultsController: resultController) //self.searchController.searchResultsUpdater = self //self.searchController.delegate = self //self.searchController.searchBar.delegate = self self.searchController.searchBar.tintColor = UIColor.whiteColor() self.searchController.searchBar.placeholder = "Search Outlets" self.searchController.dimsBackgroundDuringPresentation = false self.searchController.hidesNavigationBarDuringPresentation = false self.definesPresentationContext = true 方法。另外,LinqDataSourceSelectEvenArgs将数据存储为Any,因此请使用object获取可以运行as的{​​{1}}:

IEnumerable<T>