Link to home
Start Free TrialLog in
Avatar of bmanmike39
bmanmike39

asked on

How would i write the the following query in entity to count the number of rows in a table?

SELECT        COUNT(*) AS CNT
FROM            web_board
WHERE class_number = 45

MY entity code:
NLAMEMEntities2 oe = new NLAMEMEntities2();

var cnt = oe.web_board.Where(x =>) x.class_number == "45").Count();

label1.text = cnt.ToString();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bmanmike39
bmanmike39

ASKER

No, I get an error  the class_number is type string.  some of the numbers have letter with them.  

The error says i can't use == operator with in and string
Got it.  Thanks for the help!  I fat fingers some things.  The following worked.

var cnt = oe.web_board.Where(x => x.class_number == "45").Count();

Open in new window

Thanks again!