簡體   English   中英

兩個具有LINQ的數據庫-生成的代碼中的編譯錯誤

[英]Two Databases with LINQ - Compilation errors in generated code

我在一個VB.Net項目中將LINQ-to-SQL類添加到了兩個不同的數據庫中。 但是這樣做會在生成的代碼中產生許多編譯錯誤。

在文件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

在保存類之前在屬性中; 這兩個數據庫都有一些通用的表名,但我相信我已經限定了所有這些表名。

有誰知道是什么原因造成的,以及如何處理? 從原則上講,我可以編輯生成的文件,但是似乎有很多更改可以隨時消失。

自問了這個問題之后,我發現在兩個單獨的項目中包含兩個數據庫的類已解決了這個問題。 我不知道如果嘗試同時涉及兩個數據庫的Linq-to-SQL查詢會有什么影響,但是我沒有計划這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM