RavenDB 子类索引

发布于 2024-12-10 14:49:27 字数 832 浏览 0 评论 0原文

我正在尝试为 ProviderProfileId、Email 和 Address1 创建索引

我创建了有效的查询,但没有索引。我知道从 List 继承集合可能是问题的一部分。 List 是我必须在更旧的项目上进行大量 XmlSerialization 时遗留下来的,并成为我建模中的一种习惯。我还注意到,在 Raven 中,序列化比 AddressCollection 只是列表要干净得多。有什么想法吗?

模型类似于

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;}
}

I am trying to create an indexes for ProviderProfileId, Email, and Address1

I have created queries that work, but not indexes. I know the inheriting from List for the collections might be part of the problem. List is a carry over from when I had to do a significant amount of XmlSerialization on much older projects, and became a habit in my modeling. I also noticed that in Raven the serialization is much cleaner that if AddressCollection were just List. Any thoughts?

Model is similar to

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;}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白芷 2024-12-17 14:49:27

我现在回答一下,基本上我对linq还不够了解。一旦我明白了,就很有道理了。我试图为子集合创建索引,在本例中为地址。这不是 100% 有效,但它确实可以编译,并且当我将索引推送到服务器时它不会崩溃。

Map = collection => from item in collection where item.AddressCollection != null
                    from item2 in item.AddressCollection
                    select new {
                         item2.city
                     }

I now answered it, basically I didn't know linq well enough. Makes sense once I figured it out. I was trying to make an index for a sub collection, in this case addresses. Not 100% this works, but it does compile and when I push the index to the server it does not blow up.

Map = collection => from item in collection where item.AddressCollection != null
                    from item2 in item.AddressCollection
                    select new {
                         item2.city
                     }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文