2015-11-06 146 views
0

我正在實體框架6首次。我下載了教程並用它來啓動我的程序。我使用實體框架作爲連接到兩個不同服務器的方法來提取數據並將它們存儲在變量中。我完全按照tutuorial的方式進行設置,並採用完全相同的方式。以下是我目前在主模塊中的內容。如果還有其他東西需要看,請告訴我。希望這是足夠的信息。謝謝!無法轉換爲'System.Data.Entity.Infrastructure.DbQuery`1 []'類型的對象來鍵入'System.Data.Entity.Core.Objects.ObjectQuery`1 []

JobCodesContext = New LicensingRepository_DvlpEntities1 

    Dim JobCodeQuery As ObjectQuery(Of ControlTrackedJobCode) = 
     From Element In JobCodesContext.ControlTrackedJobCodes.Include("JobCode") 
     Select Element 
+0

的可能的複製[實體框架4.1:無法從的DBQuery到的ObjectQuery投](http://stackoverflow.com/questions/7208709/ entity-framework-4-1-capable-to-cast-from-dbquery-to-objectquery) –

+0

潛在的Lukas,但我不知道C#。儘管它們是相似的語言,但我無法確定該解決方案對我的幫助。 – mwell10

回答

0

similar question答案轉換爲VB

Dim objectContext As ObjectContext = 
    CType(JobCodesContext, IObjectContextAdapter).ObjectContext; 

Dim JobCodeQuery As ObjectQuery(Of ControlTrackedJobCode) = 
     From Element In objectContext.CreateObjectSet(Of ControlTrackedJobCode).Include("JobCode") 
     Select Element 
+0

謝謝盧卡斯!我收到以下錯誤消息:「'controlTrackedJobCodes不是System.Data.Entity.Core.Objects的成員」如何將ControlTrackedJobCodes添加到System.Data.Entity.Core.Objects.Objectcontext? – mwell10

+0

嘗試使用'CreateObjectSet(Of ControlTrackedJobCode)'而不是'ControlTrackedJobCodes' ...不確定VB中的語法是否正確 –

+0

擺脫了錯誤!謝謝! – mwell10

相關問題