开发者

LinqToSQL definition for INFORMATION_SCHEMA.ROUTINES

I've been able to successfully create definitions for Tables and Views. I'm trying to finish a Class definition for Routines. I've compared my property definitions to the information at MSDN and it looks correct. It compiles successfully, but when I try to query it I get the following exception:

System.InvalidCastException was caught
  Message="Specified cast is not valid."
  Source="System.Data"
  StackTrace:
       at System.Data.SqlClient.SqlBuffer.get_Int32()
       at Read_Object(ObjectMaterializer`1 )
       at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at AMCRM.frmSystemCheck.DBInfoRoutines()
  InnerException: 

The Table Class is defined as:

<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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜