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

bmanmike39Asked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
Except for the extraneous paren and double quotes, does what you have not work?

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

Open in new window

0
 
bmanmike39Author Commented:
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
0
 
bmanmike39Author Commented:
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

0
 
bmanmike39Author Commented:
Thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.