2015-07-02 24 views
0

在我一起工作的應用程序I recevie 18個錯誤等:無效表達術語「選擇」,「基團」等

Error 2 Invalid expression term 'select'  
Error 6 Syntax error, ',' expected 

似乎它被連接在一起。

我應該在哪裏尋找問題的根源?

類的所有這些錯誤的部分:

if (this.TicketType == "Delivery") 
{ 
    this.Drivers = new ObservableCollection<User>(this.loginService.GetAllDrivers()); 
} 
else if (this.TicketType == "Drivers") 
{ 
    IEnumerable<User> tickets = 
      from t in this.Tickets      // here error 
      where !string.IsNullOrEmpty(t.DriverName) 
      group t by t.DriverName into group   // here error 
      select new User() 
      { 
       Name = group.Key,      // here error 
       Id = (
        from g in group      // here error 
        select g.DriverId).First<int>() 
      }; 
    if (tickets == null) 
    { 
     this.Drivers.Clear(); 
    } 
    else 
    { 
     this.Drivers = new ObservableCollection<User>(tickets); 
    } 
    this.OnPropertyChanged("Drivers"); 
} 
+3

您怎樣編譯?這聽起來像它可能是一個非常古老的C#編譯器......或者當你使用'group'作爲範圍變量的名稱時,它可能會變得困惑,這沒有幫助。嘗試將'group'更改爲'groups'。如果您可以製作一個簡短但完整的示例來說明問題,那將有助於我們幫助您。 –

+1

顯示你的'使用' – maksymiuk

+0

我在Visual Studio 2013中工作,我從一個項目複製這個有問題的類到另一個,我不明白問題在哪裏...... – tauri

回答

1

您需要添加using System.Linq;

+0

奇怪的是(在使用System.Linq添加後)錯誤從類中消失了,但它們仍然在錯誤列表中,並且我無法構建 – tauri

+0

嘗試清理構建,然後執行重建。 – tdbeckett

+1

無論哪裏出現語法錯誤,如果您嘗試將鼠標懸停在受影響的關鍵字之一上,則應在Visual Studio * Resolve *中獲得一些選項,然後添加可能缺少的其他'usages'。 – maksymiuk