2011-05-05 99 views
0

我在我的LINQ中使用以下表達式來連接sql。LINQ到SQL連接

 int before = db.Employees.Count(); 

     var after = (from c in db.Employees 
        where c.emp_city == "pune" 
        select c).Count; 


     Console.WriteLine("# of Customers= {0}, In pune= {1}", before, after); 


     Console.ReadLine(); 

它給這個錯誤:

錯誤1無法分配方法組到一個隱式類型的局部變量

如何解決呢?

回答

2

你忘了實際調用的計數方法,加括號:

var after = (from c in db.Employees 
       where c.emp_city == "pune" 
       select c).Count();