In PetaPoco, how to decorate a table with multiple columns of primary keys

In the example on the PetaPoco website, 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 suppose that the articles in the table were modeled to have 2 columns: article_id and a heading as the main key (and not just article_id), what the layout in PetaPoco looks like.

+6
source share
1 answer

Currently this only works in my branch, but you can do it.

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

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

+16
source

Source: https://habr.com/ru/post/896331/


All Articles