我在 NDepend 中使用 CQLinq 计算标识符的平均长度,我想获得类、字段和方法名称的长度。我浏览了 CQlinq 的这个页面:http ://www.ndepend.com/docs/cqlinq-syntax ,我的代码如下:
let id_m = Methods.Select(m => new { m.SimpleName, m.SimpleName.Length })
let id_f = Fields.Select(f => new { f.Name, f.Name.Length })
select id_m.Union(id_f)
它不起作用,一个错误说:
“System.Collections.Generic.IEnumerable”不包含“Union”的定义...
另一个是:
无法从“System.Collections.Generic.IEnumerable”转换为“System.Collections.Generic.HashSet”
但是,根据MSDN, IEnumerable 接口定义了 Union() 和 Concat() 方法。
在我看来,我不能以与 Linq 完全相同的方式使用 CQLinq。无论如何,有没有办法在单个查询中从类型、方法和字段域中获取信息?
非常感谢。