2012-03-17 87 views
3

我使用的音樂商店的樣本數據,我有一個POCO像這樣:是否一個ID POCO屬性必須案例RavenDB敏感?

public class Album 
{ 
    public Genre Genre { get; set; } 
    public Artist Artist { get; set; } 
    public string ID { get; set; } /***** NULL *****/ 
    public string AlbumArtUrl { get; set; } 
    public double Price { get; set; } 
    public string Title { get; set; } 
    public int CountSold { get; set; } 

} 

然而,當我檢索數據的ID屬性爲null。如果我將屬性更改爲Id,那麼它將被填充。這似乎表明該財產必須是某種情況。

下面是數據:

{ 
    "AlbumArtUrl": "/Content/Images/placeholder.gif", 
    "Genre": { 
    "Id": "genres/1", 
    "Name": "Rock" 
    }, 
    "Price": 8.99, 
    "Title": "Let There Be Rock", 
    "CountSold": 0, 
    "Artist": { 
    "Id": "artists/1", 
    "Name": "AC/DC" 
    } 
} 

有趣的流派&藝術家POCO改變POCO屬性的情況下,不會有所作爲。我不知道它的,因爲它明確表明其在JSON,而標識在相冊的屬性是沒有的。

回答

2

默認情況下,我們尋找名爲「Id」的屬性,並且在屬性名稱中是套管事項

您可以通過改變Conventions.FindIdentityProperty

+2

出於興趣改變這種慣例爲何它沒有問題,如果流派/藝術家POCO是ID或ID,因爲無論臥牛它被填充 – Jon 2012-03-17 12:26:56

相關問題