2014-05-06 81 views
0

我想一個C#代碼轉換成VB代碼找不到使用VB.NET的AddOrUpdate()方法?

在C#代碼它可以調用AddOrUpdate方法,但是當我在VB代碼它它不是在智能感知找到。

C#代碼:

protected override void Seed(eManager.Web.Infrastructure.DepartmentDB context){ 
     context.Departments.AddOrUpdate(d => d.Name, 
        new Department() { Name = "Engineering"}, 
        new Department() { Name = "Sales"} 
     ); 
    } 

VB代碼:

但是,當我的代碼VB的方法AddOrUpdate(),我找不到它。 DepartmentDB類的聲明是這樣的:

Imports System 
    Imports System.Collections 
    Imports System.Collections.Generic 
    Imports System.Linq 
    Imports System.Text 
    Imports System.Threading.Tasks 
    Imports System.Data.Entity 
    Imports eManager.Domain 

    Public Class DepartmentDB 
     Inherits DbContext 
     Implements IDepartmentDataSource 

    Private _DBEmployees As DbSet(Of Employee) 
    Private _DBDepartments As DbSet(Of Department) 

    Public ReadOnly Property Departments As IQueryable(Of Department) Implements IDepartmentDataSource.Departments 
     Get 
      Return _DBDepartments 
     End Get 
    End Property 


    Public ReadOnly Property Employees As IQueryable(Of Employee) Implements IDepartmentDataSource.Employees 
     Get 
      Return _DBEmployees 
     End Get 
    End Property 
End Class 
+0

在我看來,你的圖書館,或解決方案,是不是建築的另一部分,這只是一個該症狀。 –

+0

@DominicKexel,你正在那裏,'進口'可能不存在;它是什麼名字空間? –

回答

-1

很顯然,我必須用明確的轉換爲使用IDBSet(Of T)擴展方法的AddOrUpdate()..但我不知道如何轉換Linq表達式的這個C#

context.Departments.AddOrUpdate(d => d.Name, 
       new Department() { Name = "Engineering"}, 
       new Department() { Name = "Sales"} 
    ); 

到VB代碼:

Dim depts As IDbSet(Of Department) = context.Departments 
Dim addNew = Sub(x As Department) 

      End Sub 
depts.Departments.AddOrUpdate(Linq Expression???);