我正在尝试对现有项目进行更改,并且在充满生成的类的解决方案中找到了一个项目。什么生成了这个数据库访问器代码?
问题是,在这里没有人能告诉我他们是什么产生的,所以我几乎没有在这里粘贴其中的一个类,希望有人能够告诉我他们来自哪里。
我正在使用的解决方案使用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上的东西。任何线索,任何人?
Windows搜索没有提出解决方案目录中的任何一个......我已经看到Linq-to-SQL在搜索短语“可扩展性方法定义”时提及。也许最初的编码器删除了.dbml文件... – Frosty840 2010-10-21 11:05:00
是的,t发现这个人已经生成了所有这些类,然后拆分生成的文件,然后将一些但不是全部生成的类取出来他们自己的.vb文件。顺便说一句,他是否以这种方式做事是正确的(我假定他的修改是将iNotifyPropertyChanging实现添加到类中),还是可以自动添加iNotifyPropertyChanged/Changing? – Frosty840 2010-10-21 11:36:07