在PetaPoco中,如何装饰具有多列主键的表

Kev*_*nle 7 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; }
}
Run Code Online (Sandbox Code Playgroud)

但是假设表格文章被建模为有两列:article_id和title作为主键(而不仅仅是article_id),那么PetaPoco中的装饰会是什么样子.

Sch*_*ime 16

这目前只适用于我的分支,但你可以这样做.

[PetaPoco.PrimaryKey("article_id,title")]
Run Code Online (Sandbox Code Playgroud)

我的分支可以在这里找到. https://github.com/schotime/PetaPoco