gpt4 book ai didi

c# - Fluent nHibernate - 映射字符串列表

转载 作者:太空狗 更新时间:2023-10-29 17:31:47 25 4
gpt4 key购买 nike

我有一个这样的模型(简化)

public class Post
{
public string ID { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public string AuthorName { get; set; }

public List<string> Attachments { get; set; }
}

在我的数据库中,我有一个 Post 表和一个 PostAttachment 表

帖子附件表有 2 列:

帖子编号附件 key

(这个的基础是附件上传到amazon s3,所以AttachmentKey就是s3 key)

我想做的是将 AttachmentKey 映射到返回/插入的 Post 对象的列表...

我该怎么做?

最佳答案

@ben-hughes 你几乎明白了。

您不需要另一个映射。

HasMany(x => x.Attachments)
.KeyColumn("PostID")
.Table("PostAttachment").Element("AttachmentKey");

关于c# - Fluent nHibernate - 映射字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3448331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com