2011-10-27 63 views
0

我正在使用實體框架4.0。查詢返回錯誤的結果集 - 實體框架

Custumer是我的ObjectContext中的一個實體,Enity類是自動生成的。我得到的客戶是這樣的:

Public Function GetAll(ByVal companyId As String) As System.Collections.Generic.IEnumerable(Of Customer) Implements ICustomerRepository.GetAll 
    Return Me.objectSet.Where(Function(p) p.CompId = >companyId).AsEnumerable 
End Function 

我的函數返回reult設置正確,但它並沒有選擇出只有客戶那裏Comp.Id = conmpanyId。我也嘗試過

Return From p In Me.objectSet Where p.CompId = companyId Select p 

我該如何編寫正確的查詢?

回答

0

我真的不知道VB的語法,但試試這個:

Return Me.objectSet.Where(Function(p) p => p.CompId == companyId).AsEnumerable