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 8940215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:59:08+00:00 2026-06-15T10:59:08+00:00

I have a list which has a single record i.e which matches to a

  • 0

I have a list which has a single record i.e which matches to a particular ID.

Now I want to use this list’s property(i.e. a column for that single record) without using FOREACH loop as it will just cause burden for server because my program is already having lot of loops…
Can it be done??

I am filtering the records brought from ViewState based on an ID..

var selectedPracticeInfo = 
          (List<PropPractice>) ViewState["dicPracticesInGrupWithTimeZone"];

var selectedPracticeforEncounter = 
             from selectedPractice in selectedPracticeInfo
             where 
                selectedPractice.PracticeId 
                     == Convert.ToInt32(ddlPractice.SelectedValue)
  select new PropPractice
  {
    PracticeId = selectedPractice.PracticeId,
    PracticeName = selectedPractice.PracticeName,
    TimeZoneDisplayName = selectedPractice.TimeZoneDisplayName
  };

I am planning to do something like this which will pull out the TimeZoneDisplayName of that Single record directly but it says “String cannot be used as Boolean”..

var practiceTimeZoneName 
       = selectedPracticeforEncounter
               .Single(practice=>practice.TimeZoneDisplayName

So,I wanted to ask if it can be done by some way except FOREACH??

  • 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-15T10:59:09+00:00Added an answer on June 15, 2026 at 10:59 am

    Is this something like you require? First Or Default will ensure you get a single record or null

    var result = selectedPracticeInfo
                 .Where(m=> m.PracticeID == (Int32)ddlPractice.SelectedValue)
                 .FirstOrDefault();
    
    if(result != null){
    
    var timezone = result.TimeZoneDisplayName;
    
    }
    

    result will be a type of PropPractice but for good practice use strongly defined where you can

    PropPractice = selectedPracticeInfo
                   .Where(m=> m.PracticeID == (Int32)ddlPractice.SelectedValue)
                   .FirstOrDefault();
    

    you will not need the below to create the new object:

    select new PropPractice
      {
        PracticeId = selectedPractice.PracticeId,
        PracticeName = selectedPractice.PracticeName,
        TimeZoneDisplayName = selectedPractice.TimeZoneDisplayName
      };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table articles that has a column company which has list of
I have a list which has repeating items and I want a list of
I have a main MasterPage which has a single column layout for the web
I have a function that returns a list like this:- List <Column <String1, String2>>
I have a ul list which has a few single and some multi-line li
I have a List of beans, each of which has a property which itself
I have list in python which has following entries name-1 name-2 name-3 name-4 name-1
I have a list view item which has a button and displays properties on
I have a list: Collection users which has around 100K+ records of users (all
I have a list of items of type ViewLookupItem which has these properties: For

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.