2011-10-19 29 views
-1

我試圖爲ProviderProfileId,電子郵件和地址1RavenDB指數的子類

我創建工作查詢創建一個索引,但沒有指標。我知道從List繼承集合可能是問題的一部分。列表是從我必須在大多數較老的項目上執行大量XmlSerialization轉換而來的,並且在我的建模中成爲一種習慣。我還注意到,在Raven中,如果AddressCollection只是List,則序列化會更清晰。有什麼想法嗎?

模型類似於

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

是什麼問題? 順便說一句,收集類型「SocialMediaAliasCollection」和「AddressCollection」都沒有增加價值。爲了簡單起見,我建議刪除它們。 –

+0

在大多數情況下,您的方法都是正確的,但它們並沒有增加太多價值,但是在許多情況下,在使用遺留系統時,此方法可以更好地控制XmlSerialization過程,這在我們的應用程序的許多其他部分中必須執行。你會建議IEnumerable

AddressCollection {get; set;}?這會解決索引創建問題嗎? –

+0

是的,我會建議IEnumerable

或IList
。不僅僅是它使得Json序列化更清晰,而且還能讓你的代碼更清晰。但是,我不知道它是否解決了您的問題,因爲我不知道您的問題是什麼。什麼是問題?你是如何嘗試創建一個索引,它是如何失敗的? –

回答

0

現在我回答了,基本上我不知道LINQ不夠好。一旦我明白了,這是有道理的。我試圖爲一個子集合創建一個索引,在這個例子中是address。這不是100%的工作,但它確實編譯,當我將索引推送到服務器時,它不會炸燬。

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