8

在 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 中的装饰会是什么样子。

4

1 回答 1

17

这目前仅适用于我的分支,但您可以这样做。

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

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

于 2011-09-01T02:45:54.163 回答