views:

43

answers:

0

ASP.NET 2.0; I am attempting to pass a custom type to a generic list to get a list of whatever type I send in. However I keep getting this error:

Type argument '' does not inherit from or implement the constraint type ''

What's confusing about this is I AM implementing the constraint. In fact, here is the Interface:

Public Interface ILookup
    Property ID() As Int32
    Property Text() As String
    Property Description() As String
    Property Status() As Status
    Property OrderID() As Int32
    ReadOnly Property LookUpType() As LookUpType
End Interface

And here I am implementing it in the class....

Public Class EyeColor
  Implements ILookup

...I then go on and implement all the members in the Interface.

Here I am in the UI trying to call it...

  ddlEyeColor.DataSource = luMgt.GetLookUpItemList(Of EyeColor)()

This calls down the BC an DBC which are set up with what appears to be the propr constraints....

Public Function GetLookUpItemList(Of t As {ILookup, New})() As List(Of t)
    Dim luMgt As New DBC.LookupMgt
    Return luMgt.GetLookUpItemList(Of t)()
End Function

Here is the entire class. Note that you will see it inherits a Lookup class and Implements a ILookup interface. Both sport the same members. This is why you see overridable. I tried taking out the inheritance but it didn't help...

Public Class EyeColor
    Inherits Lookup
    Implements ILookup

    'Mandatory parameterless constructor
    Public Sub New()
        MyBase.new()
    End Sub

    Private _eyeColor As String


    'Here you'll see me overiding the 
    Public Overrides Property Description() As String Implements ILookup.Description
        Get
            Return MyBase.Description
        End Get
        Set(ByVal value As String)
            MyBase.Description = value
        End Set
    End Property

    Public Overrides Property ID() As Integer Implements ILookup.ID
        Get
            Return MyBase.ID
        End Get
        Set(ByVal value As Integer)
            MyBase.ID = value
        End Set
    End Property

    Public Overrides Property OrderID() As Integer Implements ILookup.OrderID
        Get
            Return MyBase.OrderID
        End Get
        Set(ByVal value As Integer)
            MyBase.OrderID = value
        End Set
    End Property

    Public Overrides Property Status() As Status Implements ILookup.Status
        Get
            Return MyBase.Status
        End Get
        Set(ByVal value As Status)
            MyBase.Status = value
        End Set
    End Property

    'This should mirror TEXT
    Public Property EyeColor() As String Implements ILookup.Text
        Get
            Return _eyeColor
        End Get
        Set(ByVal value As String)
            _eyeColor = value
        End Set
    End Property

    Public ReadOnly Property LookUpType() As LookUpType Implements ILookup.LookUpType
        Get
            Return BE.LookUpType.EyeColor
        End Get
    End Property

End Class

Here is the DBC part Sam wanted to see...

    Public Function GetLookUpItemList(Of t As {ILookup, New})() As List(Of t)

        'Dim the generic list that will be returned
        Dim lstGenericList As New List(Of t)

'THEN CODE TO GET THE DATA FROM THE DB 


        Using (oConnection)

            oConnection.Open()
            oReader = oCmd.ExecuteReader()

            While oReader.Read
                'instantiate a new item of t
                oGenericListItem = New t

                oGenericListItem.ID = oReader.GetInt32(0)
                oGenericListItem.Text = oReader.GetString(1)
                oGenericListItem.Description = oReader.GetString(2)
                oGenericListItem.Status.StatusID = oReader.GetInt32(3)
                oGenericListItem.OrderID = oReader.GetInt32(4)

                lstGenericList.Add(oGenericListItem)
            End While

            oConnection.Close()

        End Using

        Return lstGenericList

    End Function