views:

332

answers:

0

I want to insert into one table from the properties of multiple classes using Linq. Here are some representations of my objects( I am custom creating my Linq Objects with the attributes):

<Table(Name:="Certificates")> _
Public Class Certificate : Implements ICertificate, INotifyPropertyChanged
    <Column(CanBeNull:=False, IsDbGenerated:=True, IsPrimaryKey:=True, Name:="CertificateID")> _
    Public Property Id() As Integer Implements ICertificate.Id
        Get
            Return _id
        End Get
        Set(ByVal value As Integer)
            _id = value
            NotifyPropertyChanged("Id")
        End Set
    End Property

    Public Property Owner() As IOwner Implements ICertificate.Owner
        Get
            If (_owner Is Nothing) Then
                _owner = New Owner()
            End If
            Return _owner
        End Get
        Set(ByVal value As IOwner)
            _owner = value
        End Set
    End Property
End Class

The Owner object represented in the property above is this:

<Table(Name:="Certificates")> _
Public Class Owner : Implements IOwner, INotifyPropertyChanged
 <Column(Name:="OwnerAddress")> _
    Public Property Address() As String Implements IOwner.Address
        Get
            Return _address
        End Get
        Set(ByVal value As String)
            _address = value
            NotifyPropertyChanged("Address")
        End Set
    End Property
End Class

As you can see the Owner object represents a column in the "Certifcates" table. When I do my insert I want to just send the "Certificate" into the DataContexts InsertOnSubmit statement and have Linq figure out that the "OwnersAddress" is actually a column for insert in the parent Certificate statement.

I can take answers in C# or VB

Thanks for the help.