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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:06:25+00:00 2026-06-14T07:06:25+00:00

I rewrite again my question, I didn’t expose it in the right way, sorry.

  • 0

I rewrite again my question, I didn’t expose it in the right way, sorry.

I have this SQL query:

SELECT T1.*, T2.documentNumber
FROM TABLE1 T1      
LEFT JOIN TABLE2 T2 ON      
    T2.documentNumber = (
        SELECT TOP 1 documentNumber         
        FROM TABLE2  
        WHERE description = T1.description)                                     
WHERE T1.color = 'RED';

I need to retrieve all the rows in T1 filtered by color with the corresponding T2.documentNumber value, but unique T1 rows, I mean, a relation 1 to 1 with T2.

T1 and T2 are related through description column. Because description is not unique in t2, this table can contain N rows with the same description, since I want only 1 row as result for each T1 row, I get the top 1 filtering by the unique column (documentNumber).

This query works fine for me, want I need to know is the equivalent for Linq-to-SQL, I tried for several hours but without success. Could please somebody help me?

  • 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-14T07:06:27+00:00Added an answer on June 14, 2026 at 7:06 am

    Try

    var result = table1.Where(t1 => t1.color == "RED")
                       .GroupJoin(table2,
                                  t1 => t1.description,
                                  t2 => t2.description,
                                  (t1,g) => new {
                                                  T1 = t1,
                                                  DocumentNumber = g.FirstOrDefault()
                                                 });
    

    Mandatory 101 link: http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b should help deal with these sort of queries….

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

Sidebar

Related Questions

I am posting this question again because I didn't explain clear enough. Here are
I have asked a similar question before, but I didn't have a firm grasp
url.rewrite-once = ( .*\.(js|ico|gif|jpg|png|css|html)$ => $0, ^/([^?]*)(\?.*)?$ => /$1.php/$2, ) This is what I
I have the following rewrite rule that I need to alter in order to
I have next rewrite rules: RewriteEngine ON RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}
In a previous question I was told how to rewrite my computation expressions so
I have a general IO question. I was trying to replace a single line
This is using jQuery 1.6.1 and Validate 1.8.1. I have been banging my head
This configuration is used to rewrite a URL to a sub-directory for versioning purposes,
At start, we have this basic enum. public enum E_Levels { [ValueOfEnum(Low level)] LOW,

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.