diff --git a/Attributes/ItemInstanceAttribute.vb b/Attributes/ItemInstanceAttribute.vb index 53b9071..69701d7 100755 --- a/Attributes/ItemInstanceAttribute.vb +++ b/Attributes/ItemInstanceAttribute.vb @@ -9,6 +9,8 @@ Option Strict On Option Explicit On +Imports System.Linq + ''' -------------------------------------------------------------------------------- ''' ''' Specifies the type of class instance that will represent each database record / object. @@ -26,10 +28,14 @@ Public Class ItemInstanceAttribute Private pobjType As Type ''' - ''' Indicates the + ''' Indicates the type that inherits DatabaseObject or implements IDatabaseObject. ''' Public Sub New(ByVal objType As Type) + If Not objType.GetInterfaces().Contains(GetType(IDatabaseObject)) Then + Throw New ArgumentException("Type " & objType.FullName & " passed to ItemInstanceAttribute does not implement " & GetType(IDatabaseObject).FullName) + End If + pobjType = objType End Sub diff --git a/Database/ObjectReferenceEarlyBinding.vb b/Database/ObjectReferenceEarlyBinding.vb index f3d2b35..013d75f 100644 --- a/Database/ObjectReferenceEarlyBinding.vb +++ b/Database/ObjectReferenceEarlyBinding.vb @@ -103,6 +103,7 @@ Friend Module ObjectReferenceEarlyBinding #If DEBUG Then excludeCollectionTypeNames.Add("DatabaseObjects.UnitTests.ItemInstanceTests+TableWithNoItemInstanceAttribute") + excludeCollectionTypeNames.Add("DatabaseObjects.UnitTests.AttributesInvalidTests+InvalidItemInstanceTypeCollection") #End If Return _