views:

13

answers:

1

I have class following. When i mapping file also following. I only get IList but i have not get List(of OrderTemp). Help me.

Public Class CusTemp Private _CustomerID As String Private _CompanyName As String Private _ContactName As String Private _ContactTitle As String Private _Address As String Private _City As String Private _OrderTemp As List(Of OrderTemp)

Public Sub New()

End Sub

Public Property CustomerID() As String
    Get
        Return _CustomerID
    End Get
    Set(ByVal value As String)
        _CustomerID = value
    End Set
End Property

Public Property CompanyName() As String
    Get
        Return _CompanyName
    End Get
    Set(ByVal value As String)
        _CompanyName = value
    End Set
End Property

Public Property ContactName() As String
    Get
        Return _ContactName
    End Get
    Set(ByVal value As String)
        _ContactName = value
    End Set
End Property

Public Property ContactTitle() As String
    Get
        Return _ContactTitle
    End Get
    Set(ByVal value As String)
        _ContactTitle = value
    End Set
End Property

Public Property Address() As String
    Get
        Return _Address
    End Get
    Set(ByVal value As String)
        _Address = value
    End Set
End Property

Public Property City() As String
    Get
        Return _City
    End Get
    Set(ByVal value As String)
        _City = value
    End Set
End Property


Public Property OrderTemp() As List(Of OrderTemp)
    Get
        Return _OrderTemp
    End Get
    Set(ByVal value As List(Of OrderTemp))
        _OrderTemp = value
    End Set
End Property

End Class

mappingfile:

<!--One-to-many mapping: Orders-->
<bag name="OrderTemp" table="Orders" lazy="true">
  <key column="CustomerID" />
  <one-to-many class="OrderTemp"/>
</bag>

A: 

Try using a set mapping

Then in your code you could just do

var criteria = Session.CreateCriteria(typeof(OrderTemp)).List();

Aim Kai
Declare IList(Of OrderTemp). It is ok.

related questions