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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:29:57+00:00 2026-05-20T16:29:57+00:00

Given: A table named TABLE_1 with the following columns: ID ColumnA ColumnB ColumnC ColumnD

  • 0

Given:

A table named TABLE_1 with the following columns:

  • ID
  • ColumnA
  • ColumnB
  • ColumnC
  • ColumnD

I have SQL query where TABLE_1 joins on itself twice based off of ColumnA, ColumnB, ColumnC. The query might look something like this:

Select t1.ID, t2.ID, t3.ID, LEAST(t1.ColumnD, t2.ColumnD, t3.ColumnD)
  From TABLE_1 t1
  Left Join TABLE_1 t2 On
       t1.ColumnA = t2.ColumnA
   And t1.ColumnB = t2.ColumnB
   And t1.ColumnC = t2.ColumnC
  Left Join TABLE_1 t3 On
       t2.ColumnA = t3.ColumnA
   And t2.ColumnB = t3.ColumnB
   And t2.ColumnC = t3.ColumnC

Problem:

I need that Query to be rewritten in LINQ. I’ve tried taking a stab at it:

var query =
    from t1 in myTABLE1List // List<TABLE_1>
    join t2 in myTABLE1List
      on new {t1.ColumnA, t1.ColumnB, t2.ColumnC}
  equals new {t2.ColumnA, t2.ColumnB, t2.ColumnC}
    join t3 in myTABLE1List
      on new {t2.ColumnA, t2.ColumnB, t2.ColumnC}
  equals new {t3.ColumnA, t3.ColumnB, t3.ColumnC}
  select new {
    ID_1 = s1.ID,
    ID_2 = s2.ID,
    ID_3 = s3.ID,
    // Invalid anonymous type member declarator.
    // Anonymous type members must be declared with a member assignment,
    // simple name or member access.
    // how can I implement this?
    least(s1.ColumnD, s2.ColumnD, s3.ColumnD)
  };

....

private object least(params object[] objects)
{
  // code here that sorts the objects and returns the 'smallest' of them.

  return leastObject;
}

How do I write my query in LINQ? What am I doing wrong? I thought it was possible to use functions inside of LINQ expressions, so why am I getting this error?

  • 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-20T16:29:58+00:00Added an answer on May 20, 2026 at 4:29 pm

    I could be wrong, but I think you need to assign the result of least to an actual member of your new anonymous type instance, e.g.:

    select new {
        ID_1 = s1.ID,
        ID_2 = s2.ID,
        ID_3 = s3.ID,
        Least = least(s1.ColumnD, s2.ColumnD, s3.ColumnD)
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a table named person (in a MySQL database/schema), kind of like this one:
For a given table 'foo', I need a query to generate a set of
Given a model's instance object, how can I get the database table's name? I
Given the tables: role: roleid, name permission: permissionid, name role_permission: roleid, permissionid I have
I have an XML string in which Val.responseText gives me <NewDataSet> <Table> <FieldID>21</FieldID> <TableName>F003v001</TableName>
I am trying to link two fields of a given table to the same
Given a table structure like this: CREATE TABLE `user` ( `id` int(10) unsigned NOT
Given a table (mytable) containing a numeric field (mynum), how would one go about
How can I drop all tables whose names begin with a given string? I
Given the Below Tables. How do I get the Distinct name given the other

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.