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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:58:26+00:00 2026-05-25T05:58:26+00:00

List<Foo> bar= new List<Foo>() { new Foo(){ name= xxx, sname= yyy, age= 22 },

  • 0
List<Foo> bar= new List<Foo>()
{
  new Foo(){ name= "xxx", sname= "yyy", age= 22 },
  new Foo(){ name= "zzz", sname= "ccc", age= 18 },
  new Foo(){ name= "aaa", sname= "bbb", age= 14 },
  new Foo(){ name= "ddd", sname= "fff", age= 26 },
  new Foo(){ name= "uuu", sname= "hhh", age= 17 },
};

I want to get the name, surname, age from a database table.
How can I match the values with this list?

I want to get the data; Select name From FooBar Where Id = 4 assume that the return value is John and then I want to assign the John to name property of

List<Foo> bar= new List<Foo> 

and the question is how can I do this with ADO.NET?

  • 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-25T05:58:26+00:00Added an answer on May 25, 2026 at 5:58 am

    I’m not exactly sure of what you’re asking, but I’ll go on the assumption that you might be looking to query a list of data that was returned from the database.

    You can use this code to query the list:

    List<Bar> bar = new List<Bar>() 
        { 
            new Bar() { Id = 1, Name = "John Smith" }, 
            new Bar() { Id = 2, Name = "Jane Doe" }, 
            new Bar() { Id = 3, Name = "Joe Johnson" } 
        };
    
    //query the bar list and select the name 
    string name = bar.Where(x => x.Id == 2).Select(x => x.Name).FirstOrDefault();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var list = new List<Dictionary<string, string>>{ new Dictionary<string,string>{ {id,1}, {name,foo}, }, new Dictionary<string,string>{ {id,2},
Assuming the class public class Foo { public List<Bar> Bar = new List<Bar>(); public
I have a list of Foo . Foo has properties Bar and Lum .
I have a List of Foo. Foo has a string property named Bar. I'd
Concerning data binding I have these classes: public class Foo : List<Bar> { public
List<Foo> fooList = Session[foo] as List<Foo>; fooList.Add(bar); Does the call to Add() change the
Given a list ["foo", "bar", "baz"] and an item in the list "bar" ,
I have a list of variable names, like this: ['foo', 'bar', 'baz'] (I originally
I have a List of Foo Objects. If a name appears multiple times, I
I have two classes, Foo and Bar. Each Foo has a name and a

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.