如何设置IQueryable的类型为函数返回的类型??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
private IQueryable GetArticleQueryByColumnID( long columnID) { string sqlStr = "" ; if (columnID > 0) { sqlStr = string .Format(ExSql, string .Format( " and COLUMN_ID={0} " , columnID)); } else { sqlStr = string .Format(ExSql, "" ); } switch (GetColumn(columnID).REFER_TYPE) { case 0: return _db.ExecuteQuery<V_ARTICLE_SHOW_ALL>(sqlStr).AsQueryable(); case 1: return _db.ExecuteQuery<V_ARTICLE_SHOW_REFER>(sqlStr).AsQueryable(); case 2: return _db.ExecuteQuery<V_ARTICLE_SHOW_REFER>(sqlStr).AsQueryable(); case 3: return _db.ExecuteQuery<V_ARTICLE_SHOW_DUTYTREE>(sqlStr).AsQueryable(); default : return _db.ExecuteQuery<V_ARTICLE_SHOW_REFER_ALL>(sqlStr).AsQueryable(); } } |
因为没有办法判断具体返回的集合类型
调用 GetArticleQueryByColumnID(columnID).Count();时报错:
错误 7 “System.Linq.IQueryable”不包含“Count”的定义,并且找不到可接受类型为“System.Linq.IQueryable”的第一个参数的扩展方法“Count”(是否缺少 using 指令或程序集引用?) D:\newcode2013\DWGK\DWGK\ZWW.BLL\Special\SpecialDAL.cs 268 25 ZWW.BLL