2011-05-05 101 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();