2011-08-31 20 views
6

在上PetaPoco網站給出的示例表,這是如何裝飾類:在PetaPoco,如何裝飾具有多列主鍵

[PetaPoco.TableName("articles")] 
[PetaPoco.PrimaryKey("article_id")] 
public class article 
{ 
    public long article_id { get; set; } 
    public string title { get; set; } 
    public DateTime date_created { get; set; } 
    public bool draft { get; set; } 
    public string content { get; set; } 
} 

但假設表的文章爲藍本有2列:article_id和title作爲主鍵(而不僅僅是article_id),那麼PetaPoco中的裝飾將如何。

回答

15

這目前只適用於我的分支,但你可以做到這一點。

[PetaPoco.PrimaryKey("article_id,title")] 

我的分支可以在這裏找到。 https://github.com/schotime/PetaPoco

+1

更新您的URL,雖然...是它https://github.com/schotime/PetaPoco? –

+0

已更新。感謝那。 – Schotime

+0

只是好奇,如果這個組合鍵能力已合併回TopTen分支?順便說一句NPoco是什麼?下一個PetaPoco? –