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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:22:22+00:00 2026-05-20T12:22:22+00:00

When I say simply say select c, the following code works, but I want

  • 0

When I say simply say “select c”, the following code works, but I want to select the id, first name and last name, not the entire row as it is fairly lengthy.

I am fairly new to Linq. I had this working with anonymous types, but have been instructed to define all variables (hence all the as “IEnumeralbe(of DataRow)”‘s)..but none of the examples I have come across use “Select” the way I want to and they don’t tend to go on with the for loop using the fields selected in the query.

Any advice would be greatly appreciated.

Thanks in advance!!


    Dim cands As IEnumerable(Of DataRow) = ds.Tables("Candidates").AsEnumerable()
    Dim candPlace As IEnumerable(Of DataRow) = ds.Tables("JobCandPlacement").AsEnumerable()
    Dim candComp As IEnumerable(Of DataRow) = ds.Tables(dctSearchCriteria.Values(i).ToString).AsEnumerable()
    Dim strCandID As String = ""

    Dim candMatches As IEnumerable(Of DataRow) = From c In cands, cc In candComp, cp In candPlace
                Where c.Field(Of String)("candidateID") = cc.Field(Of String)("candID") _
                AndAlso cc.Field(Of String)("compSkill") = cSkill _
              Select c("candidateID"), c("firstName"), c("lastName")

   For Each cm As DataRow In candMatches 
        strCandID = ""
        strCandID = cm("candidateID") 
        increaseCandScore(strCandID)
        If Not dtSuitableCands.Rows.Contains(strCandID) Then
            Dim dr As DataRow = dtSuitableCands.NewRow
            dr("candID") = cm("candidateID")
            dr("candFName") = cm("firstName")
            dr("candLName") = cm("lastName")
            AddNewRow(dr)
        End If
    Next
  • 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-20T12:22:23+00:00Added an answer on May 20, 2026 at 12:22 pm

    There is no point. The entire table is already in memory, so all you’ll be doing is adding overhead.
    LINQ never copies values, so the only way to optimize this is to get rid of the columns completely.

    To answer the question, you need to select an anonymous type:

    Select New With { .ID = c("candidateID"), ... }
    

    You can also use your current syntax, which is equivalent to this.

    Since you’re creating an anonymous type, you cannot declare it as IEnumerable(Of DataRow); you must use Option Infer and write Dim candMatches = From ...

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

Sidebar

Related Questions

Let's say I have the following content: Lorem Ipsum is simply dummy text of
Let's say I have a simple select query that returns the following: ID Name1
Say I have a simple view, MyView . If I do: SELECT * FROM
The docs simply say or define custom schema (non-juggling), for example, mongoose. Please note,
Say I have the following simple java bean: class MyBean { private Date startDate;
I need help with a query. Consider the following table: I need to select
If I'm explaining the following ForEach feature to someone, is it accurate to say
I have the following mysql table called test. lets say it has the data
First of all, I am not looking for jQuery solution, just simple pure Javascript
Given the following table variable, which contains let's say some 10K records: DECLARE @SomeTable

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.