【发布时间】:2011-03-27 13:33:36
【问题描述】:
我会提前说,我正在用 linq 对动态数据做一些非常可怕的事情。 但我不知道为什么这个查询无法编译:
错误 1 属性 'h__TransparentIdentifier0' 不能与类型参数一起使用
公开课程序 { 公共静态无效主要(字符串[]参数) { var docs = 新动态[0]; var q = 来自文档中的文档 其中 doc["@metadata"]["Raven-Entity-Name"] == "案例" 其中 doc.AssociatedEntities != null 来自 doc.AssociatedEntities 中的实体 where entity.Tags != null // 此处的编译器错误 来自 entity.Tags 中的标签 其中 tag.ReferencedAggregate != null 选择新的 {tag.ReferencedAggregate.Id, doc.__document_id}; } } 公共静态类 LinqOnDynamic { 私有静态 IEnumerable 选择(此对象自身) { 如果(自我 == 空) 产量中断; if (self is IEnumerable == false || self 是字符串) throw new InvalidOperationException("试图枚举" + self.GetType().Name); foreach (var item in ((IEnumerable) self)) { 收益退货项目; } } public static IEnumerable【问题讨论】: