sobsinha
sobsinha

Reputation: 1

linq to sql connection

i used following expression in my linq to sql connection.

       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();

it give this error:

Error 1 Cannot assign method group to an implicitly-typed local variable

how to resolve it?

Upvotes: 0

Views: 75

Answers (1)

jeroenh
jeroenh

Reputation: 26772

you forgot to actually call the Count method, add parentheses:

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

Upvotes: 2

Related Questions