SimpleRepository 中的父对象和子对象 [英] Parent and Child object in SimpleRepository

查看:30
本文介绍了SimpleRepository 中的父对象和子对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我希望能够在对象之间建立一对多的关系,它在 Subsonic 的 SimpleReporitory 中将如何工作?

我是否必须创建一个桥对象,然后在运行时构建我的父对象,还是内置了这种支持?

我正在寻找的是以下内容:

亚当的样板店...

<前>公开课商店私有 m_id 作为整数私有 m_Name 作为字符串私有 m_Employees 作为列表(员工)公共属性 Id() 作为整数得到返回 m_id结束获取Set(ByVal value As Integer)m_id = 值结束集最终财产公共属性名称()作为字符串得到返回 m_Name结束获取Set(ByVal value As String)m_Name = 值结束集最终财产公共财产雇员()作为列表(雇员)得到返回 m_Employees结束获取Set(ByVal value As List(Of Employee))m_Employees = 值结束集最终财产结束类公共课员工私有 m_id 作为整数私有 m_Name 作为字符串公共属性 Id() 作为整数得到返回 m_id结束获取Set(ByVal value As Integer)m_id = 值结束集最终财产公共属性名称()作为字符串得到返回 m_Name结束获取Set(ByVal value As String)m_Name = 值结束集最终财产结束课程

主要部分:

<前>Dim repo As New SimpleRepository("SubSonicObjectTest", SimpleRepositoryOptions.RunMigrations)Dim emplyee1 作为新员工emplyee1.Name = "马丁"Dim emplyee2 作为新员工emplyee2.Name = "亚当"Dim 店作为新店shop.Name = "Sub Sonic Store"shop.Employees = 新列表(员工)shop.Employees.Add(emplyee1)shop.Employees.Add(emplyee2)repo.Add(Of Shop)(shop)

我认为这应该创建 3 个表:

商店
员工
ShopsToEmployees(或其他一些命名约定)

但我只有一个 Channels 表!

解决方案

我目前正在更新 SimpleRepo 的东西,以自动创建基于集合的连接表.不容易确定多/多与 1/多 - 但我有一些想法:)

How would it work in Subsonic's SimpleReporitory if I wanted to be able to have a 1 to many relationship between objects?

Would I have to create a bridge object and then build my parent object at runtime, or is this support built in?

What I am looking for is the folowing:

Adam's Example Shop...

Public Class Shop

    Private m_id As Integer
    Private m_Name As String
    Private m_Employees As List(Of Employee)

    Public Property Id() As Integer
        Get
            Return m_id
        End Get
        Set(ByVal value As Integer)
            m_id = value
        End Set
    End Property

    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set(ByVal value As String)
            m_Name = value
        End Set
    End Property

    Public Property Employees() As List(Of Employee)
        Get
            Return m_Employees
        End Get
        Set(ByVal value As List(Of Employee))
            m_Employees = value
        End Set
    End Property

End Class

Public Class Employee

    Private m_id As Integer
    Private m_Name As String

    Public Property Id() As Integer
        Get
            Return m_id
        End Get
        Set(ByVal value As Integer)
            m_id = value
        End Set
    End Property

    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set(ByVal value As String)
            m_Name = value
        End Set
    End Property

End Class

Main bits:

        Dim repo As New SimpleRepository("SubSonicObjectTest", SimpleRepositoryOptions.RunMigrations)

        Dim emplyee1 As New Employee
        emplyee1.Name = "Martin"
        Dim emplyee2 As New Employee
        emplyee2.Name = "Adam"

        Dim shop As New Shop
        shop.Name = "Sub Sonic Store"

        shop.Employees = New List(Of Employee)
        shop.Employees.Add(emplyee1)
        shop.Employees.Add(emplyee2)

        repo.Add(Of Shop)(shop)

I think this should create 3 tables:

Shops
Employees
ShopsToEmployees (or some other naming convention)

But I only get a Channels table!

解决方案

I'm updating the SimpleRepo stuff currently to automatically create joined tables based on collections. Not easy to determine many/many vs 1/many - but I have some ideas :).

这篇关于SimpleRepository 中的父对象和子对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆