是什么生成了这个数据库访问代码?

时间:2010-10-21 10:48:58

标签: .net sql-server vb.net visual-studio-2008 xaml

我正在尝试对现有项目进行更改,并且我在解决方案中找到了一个充满生成类的项目。

问题是,这里的任何人都无法告诉我是什么产生了它们,所以我几乎不会在这里粘贴其中一个类,并希望有人能够告诉我他们来自哪里。

我正在使用的解决方案使用Expression Blend 3和Visual Studio 2008.Dunno如果相关,但我想提供尽可能多的信息,我想到的......以及这个类,它出现了在它自己的文件中,有一个“SPResults”文件,其中包含大约5000行此类访问者类。不太确定为什么EndCustomer在自己的文件中......

从我自己看到的,这个程序链接到的一个数据库中有一个存储过程,而SP的名称是“GetEndCustomers”。然后有些东西创建了一个名为“EndCustomers”的类来表示此过程的返回类型。

第一部分是来自名为Database的类的函数,该类返回有问题的对象的集合。

<FunctionAttribute(Name:="dbo.GetEndCustomers")> _
Public Function GetEndCustomers(<Parameter(Name:="Dummy", DbType:="VarChar(1)")> ByVal Dummy As String) As ISingleResult(Of Data.EndCustomer)
    Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod, MethodInfo), Dummy)
    Return CType(result.ReturnValue, ISingleResult(Of Data.EndCustomer))
End Function

这部分是EndCustomer类本身。

Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.Linq
Imports System.Linq.Expressions
Imports System.Reflection

Namespace Data

<Table(Name:="dbo.EndCustomers")> _
Partial Public Class EndCustomer
        Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged

        Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty)

        Private _ID As Byte

        Private _Name As String

#Region "Extensibility Method Definitions"
        Partial Private Sub OnLoaded()
        End Sub
        Partial Private Sub OnValidate(ByVal action As System.Data.Linq.ChangeAction)
        End Sub
        Partial Private Sub OnCreated()
        End Sub
        Partial Private Sub OnIDChanging(ByVal value As Integer)
        End Sub
        Partial Private Sub OnIDChanged()
        End Sub
        Partial Private Sub OnNameChanging(ByVal value As String)
        End Sub
        Partial Private Sub OnNameChanged()
        End Sub
#End Region

        Public Sub New()
            MyBase.New()

            OnCreated()
        End Sub

        <Column(Storage:="_ID", AutoSync:=AutoSync.OnInsert, DbType:="TinyInt NOT NULL IDENTITY", IsPrimaryKey:=True, IsDbGenerated:=True)> _
        Public Property ID() As Byte
            Get
                Return Me._ID
            End Get
            Set(ByVal value As Byte)
                If ((Me._ID = value) _
                   = False) Then
                    Me.OnIDChanging(value)
                    Me.SendPropertyChanging()
                    Me._ID = value
                    Me.SendPropertyChanged("ID")
                    Me.OnIDChanged()
                End If
            End Set
        End Property

        <Column(Storage:="_Name", DbType:="VarChar(40) NOT NULL", CanBeNull:=False)> _
        Public Property Name() As String
            Get
                Return Me._Name
            End Get
            Set(ByVal value As String)
                If (String.Equals(Me._Name, value) = False) Then
                    Me.OnNameChanging(value)
                    Me.SendPropertyChanging()
                    Me._Name = value
                    Me.SendPropertyChanged("Name")
                    Me.OnNameChanged()
                End If
            End Set
        End Property

        Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging

        Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

        Protected Overridable Sub SendPropertyChanging()
            If ((Me.PropertyChangingEvent Is Nothing) _
               = False) Then
                RaiseEvent PropertyChanging(Me, emptyChangingEventArgs)
            End If
        End Sub

        Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String])
            If ((Me.PropertyChangedEvent Is Nothing) _
               = False) Then
                RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
            End If
        End Sub
    End Class

End Namespace

所以,是的,任何人都可以告诉我生成这门课程的用途是什么吗?它可能是Visual Studio,Expression Blend,SQL Server Management Studio中的一些东西,或者我在PC上甚至没有注意到的一些模糊的软件。任何线索,任何人?

1 个答案:

答案 0 :(得分:3)

看起来像Linq2Sql或EntityFramework生成的类。

检查您的项目是否包含.edmx(EntityFramework)或.dbml(Linq2Sql)文件,并且您找到了“罪魁祸首”。