In PetaPoco, how to decorate a table that has multi-columns primary keys

非 Y 不嫁゛ 提交于 2019-11-29 19:27:53

问题


In the example given on PetaPoco's web site, this is how to decorate a class:

[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; }
}

But assume that the table articles was modeled to have 2 columns: article_id and title as its primary key (instead of just article_id), then how the decoration in PetaPoco would look like.


回答1:


This currently only works in my branch, but you can do this.

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

My branch can be found here. https://github.com/schotime/PetaPoco



来源:https://stackoverflow.com/questions/7258553/in-petapoco-how-to-decorate-a-table-that-has-multi-columns-primary-keys

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!