我已将LINQ-to-SQL类添加到单个VB.Net项目中的两个不同数据库中。但这样做会在生成的代码中创建大量编译错误。
在文件FirstDB.designer.vb中,错误是: -
2 of: 'Protected Overridable Sub SendPropertyChanged(propertyName As String)' has multiple definitions with identical signatures.
2 of: 'Protected Overridable Sub SendPropertyChanging()' has multiple definitions with identical signatures.
2 of: 'Public Sub New()' has multiple definitions with identical signatures.
在文件SecondDB.designer.vb中,错误是: -
2 of: 'emptyChangingEventArgs' is already declared as 'Private Shared emptyChangingEventArgs As System.ComponentModel.PropertyChangingEventArgs' in this class.
2 of: 'PropertyChanged' is already declared as 'Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs)' in this class.
2 of: 'PropertyChanging' is already declared as 'Public Event PropertyChanging(sender As Object, e As System.ComponentModel.PropertyChangingEventArgs)' in this class.
2 of: Attribute 'TableAttribute' cannot be applied multiple times.
2 of: Method 'OnCreated' cannot be declared 'Partial' because only one method 'OnCreated' can be marked 'Partial'.
2 of: Method 'OnLoaded' cannot be declared 'Partial' because only one method 'OnLoaded' can be marked 'Partial'.
2 of: Method 'OnValidate' cannot be declared 'Partial' because only one method 'OnValidate' can be marked 'Partial'.
在第二个类中保存表后,这些错误会立即出现在错误列表中。我尝试从头开始重新创建这两个类,并尝试使用数据库名称限定所有表名: -
FirstDB.dbo.mytable
SecondDB.dbo.mytable
保存类之前的属性中的;两个数据库都有一些共同的表名,但我相信我已经对所有数据库都进行了限定。
有谁知道造成这种情况的原因以及该怎么办?我原则上可以编辑生成的文件,但这似乎有很多变化,可以随时消失。
答案 0 :(得分:0)
自从提出这个问题以来,我发现在两个独立的项目中包含两个数据库的类已经解决了这个问题。我不知道如果我尝试涉及两个数据库的Linq-to-SQL查询会产生什么影响,但我没有计划这样做。