Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:30:42+00:00 2026-06-17T10:30:42+00:00

Given the following very simple linq statement vm.VerifiedGroups = db.ReportGroups.Count(g => g.Verified); or vm.VerifiedGroups

  • 0

Given the following very simple linq statement

vm.VerifiedGroups = db.ReportGroups.Count(g => g.Verified);

or

vm.VerifiedGroups = db.ReportGroups.Count(g => g.Verified == true);

where Verified is a bool, I get an exception saying this is not supported by linq-2-entities?

Have a missed something very simple – or should I choose one from:

a)
vm.VerifiedGroups = db.ReportGroups.Where(g => g.Verified).Count();

or

b)
vm.VerifiedGroups = db.ReportGroups.ToList().Count(g => g.Verified);

both these work (and my list is only 30-50 long, so ToList isn’t a problem).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:30:44+00:00Added an answer on June 17, 2026 at 10:30 am

    You haven’t missed anything. Count with predicate is not supported by Linq to Entitities. See msdn article Supported and Unsupported LINQ Methods (LINQ to Entities)

    And yes, you should go with first option, because ToList() will execute query and bring all entities into memory:

    vm.VerifiedGroups = db.ReportGroups.Where(g => g.Verified).Count();
    

    Even if you don’t have many records in your ReportGroups table – why would you do something, which is slower, and uses more pc, database and network resources? Compare transferring one integer value to transferring all fields of 50 ReportGroup entities, creating .net objects from DataReader (and holding connection opened), and iterating over created list, executing predicate method on each of DataReader entities. I think transferring one integer value wins here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a LINQ newbie, so the following might turn out to be very simple
Given a very simple string[] , I am trying to accomplish the following in
Given the following very simple table: Create Table tblUserLogins ( LoginNumber int PRIMARY KEY
I might be asking very simple question, but i am not able to get
everybody out there i write a very simple c code which is following: #include<stdio.h>
A while back I set up the following to have a very simple image
I had the following very simple code that, of course, worked : <Image Source=Resources\data_store.png/>
I'm getting the following error when trying to build my very simple webservice project.
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.