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

  • Home
  • SEARCH
  • 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 483587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:12:46+00:00 2026-05-13T01:12:46+00:00

I am writing a LINQ query which has a sort of subquery. It looks

  • 0

I am writing a LINQ query which has a sort of subquery. It looks like this:

        var x = from p in pc
                let Cntrs = p.GetCounters().Where(args => args.CounterName == CounterName)
                select Cntrs;

Cntrs is a PerformanceCounter object. However, the intellisense returns it as a collection with collection methods.

I don’t see the properties such as NextValue, etc (which is what I want).

What am I missing? Also, and I know this must have been asked before, what’s the difference between the let and into keywords?

Thanks

  • 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-05-13T01:12:47+00:00Added an answer on May 13, 2026 at 1:12 am

    This means that the Where method is returning more than one instance, in other words you have more than one counter whose name equals the value of your CounterName variable.

    If you don’t care which one you get you can use the FirstOrDefault extension method to retrieve the first item from the sequence that is being returned from the Where like this:

    var x = from p in pc
            let Cntrs = p.GetCounters()
                         .Where(args => args.CounterName == CounterName)
                         .FirstOrDefault()
            select Cntrs;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a linq query which looks (after some simplification) something like the following:
I'm writing a linq-to-sql query that joins 4 tables. I have something like this:
I am writing a LINQ query similar to the following: var test = from
I was writing a simple LINQ query which compares rows of a table with
When you are writing a linq query that involves two tables/entities for which you
I am working on a c# project and writing a LINQ query, in this
I need help re-factoring this legacy LINQ-SQL code which is generating around 100 update
I'm writing a simple LINQ to XML query. As often, the some elements might
I have an NHibernate Linq query which isn't working how I would expect. The
What is the scope of local variable declared in Linq Query. I was writing

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.