0

可以说我有这个IQueryable变量:

var result= (from fruit in fruitTable 
                 join dapple in applesIQuery on fruit.fruitType equals dapple.fruitType into apples 
                 from apple in apples.DefaultIfEmpty()
                 select new foo );

applesIQuery 来自另一个IQueryable由另一组联接组成的。

applesIQuery =(from a in anotherTable select new {id = foo}) ;

我需要处理的情况applesIQuery == null,基本上是创建一个 id=0 的 1 个元素的列表,但没有将 转换IQueryableIEnumerable. 就像是 :

applesIQuery =(from a in anotherTable select new {id = foo})?? Iqueriable {new {id=0}} ;

任何指向正确方向的指针?

4

1 回答 1

1

applesIQuery 是 IQueryable 类型,不会为空。假设您的意思是如果查询不返回任何结果,请尝试以下操作:

applesIQuery = applesIQuery.Count() == 0 ? new ArrayList(){ new { id = 0 } }.AsQueryable() : applesIQuery;
于 2013-03-26T21:39:23.707 回答