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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:22:10+00:00 2026-05-14T08:22:10+00:00

I have to concat 2 linq2sql query and I have an issue since the

  • 0

I have to concat 2 linq2sql query and I have an issue since the 2 query doesn’t return the same number of columns, what is weird is after a .ToList() on the queries, they can concat without problem.

The reason is, for some linq2sql reason, I have 2 more column named test and test2 which come from 2 left outer join that linq2sql automatically create, something like “select 1 as test, tablefields”

Is there any good reason for that? how to remove this extra “1 as test” field?

here a few of examples of what it look like: google result for linq 2 sql “select 1 as test”

  • 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-14T08:22:10+00:00Added an answer on May 14, 2026 at 8:22 am

    OK, let’s assuming we have 2 tables: dbo.User and dbo.Client. Each client may be connected (or not) to user. So client records have a nullable foreign key field identifying a user.

    For the query:

    var query = context.Clients
          .Select(c => c.User);
    

    LINQ will produce something similar to:

    SELECT [t2].[test], [t2].[Id], [t2].[Username], ...
    FROM [dbo].[Client] AS [t0]
    LEFT OUTER JOIN (
        SELECT 1 AS [test], [t1].[Id], [t1].[Username], ...
        FROM [dbo].[User] AS [t1]
        ) AS [t2] ON [t2].[Id] = [t0].[UserId]
    

    Since not all client records have a matching user record, LINQ is creating a query that ensures there will be a row filled with nulls for every userless client. This is done by creating an extra dummy column called [test].

    So rows which have [test] column value set to 1 are really connected to user entity.

    I suppose this [test] column is used by LINQ as a flag that means “hey, here is a client with user defined”.

    If I decide to rewrite this query, I’ll use user primary key as the indicator, but it seems for LINQ it is easier to use [test] column.

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

Sidebar

Related Questions

I have two JSON objects with the same structure and I want to concat
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Have you determined a maximum number of characters allowed in FCKEditor ? I seem
Have a n-tire web application and search often times out after 30 secs. How
i have some formula: CONCAT((SUM(X.lot_qty)-SUM(X.reject))/SUM(X.accept)*100,'%') AS Acceptance but i get result like: 100.0000% how
I have this: SELECT CONCAT(forename,' ',IFNULL(initials, ''),' ',surname) AS name FROM users How do
I have the following query: select group_concat(customer_name) customer_names, count(customer_name) number_of_customers, line_1, line_2, city, state_name,
I have the following definition of a boost::function object: typedef boost::function<std::string (std::string, std::string)> concat;
I have the following xsl : <xsl:key name=kEventslegal match=HISTORY_EVENT use=concat(generate-id( preceding-sibling::HISTORY_EVENT[ @Name='Item Acceptance Review
i have a problem during count data use this query: SELECT A.*, COUNT( B.Serial_number

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.