0

我有以下用于 Linq TO Lucene 的文档规范

public class Doc1
{
 public Doc1()
 {
    Docs = new List<Doc2>();
 }
  private IList<Doc2> Docs{get;set;}
}

public Class Doc2
{
 //whatever 
}

问题是当我尝试像这样使用它时

   var provider = new LuceneDataProvider(directory, Version.LUCENE_30);
   using (var session = provider.OpenSession<Doc1>())
   {
        var m = new Doc1();
        session.Add(m);
   }

问题是当我执行此代码时,出现以下错误

System.Collections.Generic.IList`1[Doc1] 类型的属性事件无法从 System.String 转换

请问有没有其他方法可以做到这一点

提前致谢

这是完整的堆栈跟踪

[NotSupportedException: Property Event of type      System.Collections.Generic.IList`1[Doc2] cannot be converted from System.String]
   Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.GetConverter(PropertyInfo p, Type type, FieldAttribute metadata) +487
 Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.BuildPrimitive(PropertyInfo p, Type type, FieldAttribute metadata, Version version, Analyzer externalAnalyzer) +63
  Lucene.Net.Linq.Mapping.FieldMappingInfoBuilder.Build(PropertyInfo p, Version version, Analyzer externalAnalyzer) +364
Lucene.Net.Linq.Mapping.ReflectionDocumentMapper`1.BuildFieldMap(IEnumerable`1 props) +184
Lucene.Net.Linq.Mapping.ReflectionDocumentMapper`1..ctor(Version version, Analyzer externalAnalyzer) +77
Lucene.Net.Linq.LuceneDataProvider.OpenSession(ObjectLookup`1 lookup) +67
Lucene.Net.Linq.LuceneDataProvider.OpenSession(ObjectFactory`1 factory) +142
Lucene.Net.Linq.LuceneDataProvider.OpenSession() +114
4

0 回答 0