我正在尝试对现有项目进行更改,并且我在解决方案中找到了一个充满生成类的项目。
问题是,这里没有人能告诉我是什么生成了它们,所以我几乎只能将其中一个类粘贴到这里,并希望有人能够告诉我它们来自哪里。
我正在研究的解决方案使用 Expression Blend 3 和 Visual Studio 2008。不知道这是否相关,但我试图提供尽可能多的信息...以及出现的此类在它自己的文件中,有一个“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 上的一些不起眼的软件。有任何线索吗?
最佳答案
它看起来像 Linq2Sql 或 EntityFramework 生成的类。
检查您的项目是否包含 .edmx
(EntityFramework) 或 .dbml
(Linq2Sql) 文件,您已经找到了“罪魁祸首”。
关于.net - 是什么生成了这个数据库访问器代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3986608/