Fluentnhibnate:如何映射列表的元素

发布于 2025-01-23 16:46:33 字数 510 浏览 3 评论 0原文

我有以下类别:

public abstract class AbstractGeometry : IGeometry
{
    // something
}

public class CompositeGeometry : AbstractGeometry
{
    IGeometry MainGeometry { get; set; }
    IList<IGeometry> Geometries { get; set; }
}

因此,复合地体测定法具有MAINE计量学和几何形状列表。任何给定的几何形状都可以属于多个复合地理。

我有一个用于抽象测定法的映射类,另一个用于复合地理的映射类。

现在我想知道:是否可以处理复合地体图映射类中的几何列表的映射?

在数据库中,我已经创建了三个表:抽象地体测定法,复合地理测定法和复合地理计。

复合地理表包含一个抽象的测定法和Maingemetryid。

复合元素表包含一个复合地体晶体和一个抽象的分析化。

I have the following classes:

public abstract class AbstractGeometry : IGeometry
{
    // something
}

public class CompositeGeometry : AbstractGeometry
{
    IGeometry MainGeometry { get; set; }
    IList<IGeometry> Geometries { get; set; }
}

So the CompositeGeometry has a MainGeometry and a list of geometries. Any given geometry may belong to multiple CompositeGeometries.

I have a mapping class for AbstractGeometry and another mapping class for CompositeGeometry.

Now I was wondering: Is it possible to handle the mapping for the list of Geometries in the mapping class of CompositeGeometry?

In the database I already created three tables: AbstractGeometry, CompositeGeometry and CompositeGeometryElements.

The CompositeGeometry table contains a AbstractGeometryId and a MainGeometryId.

The CompositeGeometryElements table contains a CompositeGeometryId and a AbstractGeometryId.

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

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

发布评论

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

评论(1

番薯 2025-01-30 16:46:34
public class AbstractGeometryMap : ClassMap<CompositeGeometry>
{
    public AbstractGeometryMap()
    {
        Id(x => x.Id);
    }
}

public class CompositeGeometryMap : SubclassMap<CompositeGeometry>
{
    public CompositeGeometryMap()
    {
        References(x => x.MainGeometry, "MainGeometryId");
        HasManyToMany(x => x.Geometries)
            .Table("CompositeGeometryElements")
            .ParentKeyColumn("CompositeGeometryId")
            .ChildKeyColumn("CompositeGeometryId");
    }
}
public class AbstractGeometryMap : ClassMap<CompositeGeometry>
{
    public AbstractGeometryMap()
    {
        Id(x => x.Id);
    }
}

public class CompositeGeometryMap : SubclassMap<CompositeGeometry>
{
    public CompositeGeometryMap()
    {
        References(x => x.MainGeometry, "MainGeometryId");
        HasManyToMany(x => x.Geometries)
            .Table("CompositeGeometryElements")
            .ParentKeyColumn("CompositeGeometryId")
            .ChildKeyColumn("CompositeGeometryId");
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文