子类上的RavenDB索引
我正在尝试为ProviderProfileId、电子邮件和地址1创建索引 我创建了有效的查询,但没有创建索引。我知道集合的继承自列表可能是问题的一部分。这个列表是我不得不在更老的项目上进行大量XmlSerialization的时候遗留下来的,并成为我建模的一个习惯。我还注意到,在Raven中,如果AddressCollection只是一个列表,那么序列化要干净得多。有什么想法吗 模型类似于子类上的RavenDB索引,ravendb,Ravendb,我正在尝试为ProviderProfileId、电子邮件和地址1创建索引 我创建了有效的查询,但没有创建索引。我知道集合的继承自列表可能是问题的一部分。这个列表是我不得不在更老的项目上进行大量XmlSerialization的时候遗留下来的,并成为我建模的一个习惯。我还注意到,在Raven中,如果AddressCollection只是一个列表,那么序列化要干净得多。有什么想法吗 模型类似于 public class Customer { public string Id {get;set}
public class Customer {
public string Id {get;set}
public string Name {get;set;}
public AddressCollection {get;set;}
public SocialMediaAliasCollection {get;set;}
}
public class SocialMediaAliasCollection:List<SocialMedialProfile>{}
public class SocialMediaProfile{
public string ProviderProfileId {get;set;}
public string Email {get;set;}
}
public class AddressCollection:List<Address>{}
public class Address{
public string Address {get;set;}
public string City {get;set;}
public string State {get;set;}
public string Zip {get;set;}
}
公共类客户{
公共字符串Id{get;set}
公共字符串名称{get;set;}
公共地址集合{get;set;}
公共社会媒体联盟集合{get;set;}
}
公共类SocialMediaAliasCollection:列表{}
公共类社会中介文件{
公共字符串ProviderProfileId{get;set;}
公共字符串电子邮件{get;set;}
}
公共类AddressCollection:列表{}
公共课堂演讲{
公共字符串地址{get;set;}
公共字符串City{get;set;}
公共字符串状态{get;set;}
公共字符串Zip{get;set;}
}
我现在回答了,基本上我对林克还不够了解。一旦我弄明白了就有意义了。我试图为一个子集合建立索引,在本例中是地址。这并不是100%有效,但它可以编译,当我将索引推送到服务器时,它不会崩溃
Map = collection => from item in collection where item.AddressCollection != null
from item2 in item.AddressCollection
select new {
item2.city
}
问题是什么?顺便说一句,两种集合类型“SocialMediaAliasCollection”和“AddressCollection”都不会增加值。为了简单起见,我建议删除它们。在大多数情况下,您是对的,它们不会增加太多价值,但在许多情况下,当使用遗留系统时,这种方法可以更好地控制XmlSerialization过程,这是我们在应用程序的许多其他部分必须完成的。您建议IEnumerable AddressCollection{get;set;}做什么?这能解决索引创建问题吗?是的,我建议改为IEnumerable或IList。它不仅使Json序列化更干净,而且使您的代码更干净。然而,我不知道它是否解决了你的问题,因为我不知道你的问题是什么。问题是什么?您是如何尝试创建索引的?它是如何失败的?