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

发布于 2024-12-02 02:23:00 字数 456 浏览 1 评论 0原文

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

但是假设表 items 被建模为有 2 列:article_id 和 title 作为其主键(而不是只有article_id),那么 PetaPoco 中的装饰如何看起来像。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很糊涂小朋友 2024-12-09 02:23:00

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

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文