Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2015-01-14
4
120 Views
Last Modified: 2015-01-14
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

0
Comment
Question by:bmanmike39
  • 3
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40550624
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
 

Author Comment

by:bmanmike39
ID: 40550667
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
 

Author Comment

by:bmanmike39
ID: 40550678
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
 

Author Closing Comment

by:bmanmike39
ID: 40550688
Thanks again!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Iteration Help (Asp.net VB) 5 24
Open a link in vb.net 2 15
Tracing a live website down to the files which support it 2 24
abstract class C# 1 30
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question