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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:13:15+00:00 2026-05-15T07:13:15+00:00

I have a quick linq question. I have a stored proc that should return

  • 0

I have a quick linq question. I have a stored proc that should return one row of data. I would like to use a lambda to build an object. Here’s what I’m currently doing which works, but I know I should be able to use First instead of Select except I can’t seem to get the syntax correct. Can anyone straighten me out here? Thanks for any help.

 var location = new GeoLocationDC();
 DataSet ds = db.ExecuteDataSet(dbCommand);
 if(ds.Tables[0].Rows.Count == 1)
            {
                 var rows = ds.Tables[0].AsEnumerable();
                 var x = rows.Select(
                     c => new GeoLocationDC
                              {
                                  Latitude = Convert.ToInt32(c.Field<string>("LATITUDE")),
                                  Longitude = Convert.ToInt32(c.Field<string>("LONGITUDE"))
                              }).ToList();
                 if(x.Count > 0 )
                 {
                     location = x[0];
                 }

Cheers,
~ck
}

  • 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-15T07:13:16+00:00Added an answer on May 15, 2026 at 7:13 am

    You don’t need to use Select – since you know there is exactly 1 row, you can use it directly:

    var location = new GeoLocationDC();
    var ds = db.ExecuteDataSet(dbCommand);
    
    if(ds.Tables[0].Rows.Count == 1)
    {
        var row = ds.Tables[0].AsEnumerable().Single();
    
        location.Latitude = row.Field<int>("LATITUDE");
        location.Longitude = row.Field<int>("LONGITUDE");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quick question that I need some help with if possible. Am
I have a quick question. I'm matching class names of LI elements to turn
I have a quick question regarding the scale effect... I have a crude animation
I have a quick question about jQuery selectors. Is doing this: $('.class_el_1, .class_el_2').hide(); The
Note: I am aware of the earlier question What is the purpose of LINQ's
Morning all. Just a quick one for you - where can I find the
I am writing my first little Access 2003 application. I have two queries that
Possible Duplicate: What is the LINQ way to implode/join a string array? Say I
Did a quick search on SO, couldn't find what I need: I am in
I have the following structure. public class ToolSettings { public string Extension { get;

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.