查询返回错误的结果集 - 实体框架

时间:2011-10-27 11:56:52

标签: entity-framework linq-to-entities

我正在使用Entity Framework 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 

如何正确编写查询?

1 个答案:

答案 0 :(得分:0)

我真的不知道VB的语法,但试试这个:

 Return Me.objectSet.Where(Function(p) p => p.CompId == companyId).AsEnumerable
相关问题