2017-10-06 56 views
0
Using _webDataDBContext As New WebDataEntities() 
      Dim results = _webDataDBContext.coverageareas.Select(Function(x) x) 

      If String.IsNullOrEmpty(city) = False Then 
       results.Where(Function(x) x.City = city) 
      End If 

      If String.IsNullOrEmpty(county) = False Then results.Where(Function(x) x.County = county) 

      If String.IsNullOrEmpty(state) = False Then results.Where(Function(x) x.State = state) 

      If String.IsNullOrEmpty(zip) = False Then results.Where(Function(x) x.Zip = zip) 

      Return Await results.ToArrayAsync() 
     End Using 

不知道爲什麼這不起作用,當我的if語句滿意時我想追加一個where語句到我的結果。實體框架倍數基於如果沒有被添加

但是,即使語句滿足,這些位置也不會被添加。有人知道爲什麼

+0

im dumb,我需要把結果=陳述 – Andrew

回答

1

您必須將Where語句分配給IQueryable。

results = results.Where(...) 
+1

不能相信我錯過了哈哈 – Andrew