我已经能够成功地为表和视图创建定义。我正在尝试完成例程的类定义。我已经将我的属性定义与MSDN上的信息进行了比较,它看起来是正确的。它编译成功,但是当我尝试查询它时,出现以下异常:
System.InvalidCastException 被捕获 Message="指定的演员表无效。" 源="系统.数据" 堆栈跟踪: 在 System.Data.SqlClient.SqlBuffer.get_Int32() 在 Read_Object(ObjectMaterializer`1) 在 System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext() 在 System.Collections.Generic.List`1..ctor(IEnumerable`1 集合) 在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 源) 在 AMCRM.frmSystemCheck.DBInfoRoutines() 内部异常:
表类定义为:
<Table(Name:="INFORMATION_SCHEMA.ROUTINES")> _
Partial Public Class Routine
Inherits Linq2SQL
Private _SPECIFIC_CATALOG As String
Private _SPECIFIC_SCHEMA As String
Private _SPECIFIC_NAME As String
Private _ROUTINE_CATALOG As String
Private _ROUTINE_SCHEMA As String
Private _ROUTINE_NAME As String
Private _ROUTINE_TYPE As String
Private _ROUTINE_BODY As String
Private _ROUTINE_DEFINITION As String
Private _DATATYPE As String
Private _CHARMAXLEN As Nullable(Of Integer)
Private _CREATED As DateTime
Private _LAST_ALTERED As DateTime
Public Sub New()
MyBase.New()
End Sub
<Column(Name:="SPECIFIC_CATALOG", Storage:="_SPECIFIC_CATALOG")> _
Public Property specificcatalog() As String
Get
Return _SPECIFIC_CATALOG
End Get
Set(ByVal value As String)
_SPECIFIC_CATALOG = value
End Set
End Property
<Column(Name:="SPECIFIC_SCHEMA", Storage:="_SPECIFIC_SCHEMA")> _
Public Property specificschema() As String
Get
Return _SPECIFIC_SCHEMA
End Get
Set(ByVal value As String)
_SPECIFIC_SCHEMA = value
End Set
End Property
<Column(Name:="SPECIFIC_NAME", Storage:="_SPECIFIC_NAME")> _
Public Property specificname() As String
Get
Return _SPECIFIC_NAME
End Get
Set(ByVal value As String)
_SPECIFIC_NAME = value
End Set
End Property
<Column(Name:="ROUTINE_CATALOG", Storage:="_ROUTINE_CATALOG")> _
Public Property routinecatalog() As String
Get
Return _ROUTINE_CATALOG
End Get
Set(ByVal value As String)
_ROUTINE_CATALOG = value
End Set
End Property
<Column(Name:="ROUTINE_SCHEMA", Storage:="_ROUTINE_SCHEMA")> _
Public Property routineschema() As String
Get
Return _ROUTINE_SCHEMA
End Get
Set(ByVal value As String)
_ROUTINE_SCHEMA = value
End Set
End Property
<Column(Name:="ROUTINE_NAME", Storage:="_ROUTINE_NAME")> _
Public Property routinename() As String
Get
Return _ROUTINE_NAME
End Get
Set(ByVal value As String)
_ROUTINE_NAME = value
End Set
End Property
<Column(Name:="ROUTINE_TYPE", Storage:="_ROUTINE_TYPE")> _
Public Property routinetype() As String
Get
Return _ROUTINE_TYPE
End Get
Set(ByVal value As String)
_ROUTINE_TYPE = value
End Set
End Property
<Column(Name:="ROUTINE_BODY", Storage:="_ROUTINE_BODY")> _
Public Property routinebody() As Integer
Get
Return _ROUTINE_BODY
End Get
Set(ByVal value As Integer)
_ROUTINE_BODY = value
End Set
End Property
<Column(Name:="ROUTINE_DEFINITION", Storage:="_ROUTINE_DEFINITION")> _
Public Property routinedefinition() As String
Get
Return _ROUTINE_DEFINITION
End Get
Set(ByVal value As String)
_ROUTINE_DEFINITION = value
End Set
End Property
<Column(Name:="DATA_TYPE", Storage:="_DATATYPE")> _
Public Property datatype() As String
Get
Return _DATATYPE
End Get
Set(ByVal value As String)
_DATATYPE = value
End Set
End Property
<Column(Name:="CHARACTER_MAXIMUM_LENGTH", CanBeNull:=True, Storage:="_CHARMAXLEN", DbType:="Int")> _
Public Property charmaxlen() As Nullable(Of Integer)
Get
Return _CHARMAXLEN
End Get
Set(ByVal value As Nullable(Of Integer))
_CHARMAXLEN = value
End Set
End Property
<Column(Name:="CREATED", CanBeNull:=True, Storage:="_CREATED")> _
Public Property created() As DateTime
Get
Return _CREATED
End Get
Set(ByVal value As DateTime)
_CREATED = value
End Set
End Property
<Column(Name:="LAST_ALTERED", CanBeNull:=True, Storage:="_LAST_ALTERED")> _
Public Property lastaltered() As DateTime
Get
Return _LAST_ALTERED
End Get
Set(ByVal value As DateTime)
_LAST_ALTERED = value
End Set
End Property
End Class