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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:44:05+00:00 2026-06-17T10:44:05+00:00

I stumbled upon this LINQ query while reading a book. var binary = new

  • 0

I stumbled upon this LINQ query while reading a book.

var binary = new int[] { 0, 1 };

var q = from b4 in binary
        from b3 in binary
        from b2 in binary
        from b1 in binary
        select String.Format("{0}{1}{2}{3}", b4, b3, b2, b1);

foreach (var element in q)
    Console.WriteLine(element);

The result of the above LINQ will be

0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

I wanted to see how this will be in SQL Server.

What I have tried:

create table LINQ(x bit)
insert LINQ select 0
insert LINQ select 1

create table LINQ(x bit, y bit)
insert LINQ select 0,1

I tried using LINQPAD (does not give the SQL or lambda version), using the above temp tables. I tried cross join, full join. I did not get the SQL which gives the same result as LINQ.

  • 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-17T10:44:06+00:00Added an answer on June 17, 2026 at 10:44 am
    SELECT CAST(l1.x as varchar(4)) + CAST(l2.x as varchar(4))+ CAST(l3.x as varchar(4)) + CAST(l4.x as varchar(4))
    FROM LINQ as l1, LINQ as l2, LINQ as l3, LINQ as l4
    ORDER BY l1.x, l2.x, l3.x, l4.x
    

    sqlfiddle here

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

Sidebar

Related Questions

I stumbled upon this code: static void Main() { typeof(string).GetField(Empty).SetValue(null, evil);//from DailyWTF Console.WriteLine(String.Empty);//check //how
I've stumbled upon this code: var knownSeparators = new[] { \\, /, |, .
I stumbled upon this T-SQL query created on a SQL Server 2005 database: Select
While reading up on SQLite, I stumbled upon this quote in the FAQ: Threads
I was solving practice questions from a book when I stumbled upon this one
I stumbled upon this while trying to build an ActiveX dll from an old
I stumbled upon this piece of code while reading about DES encryption. I wonder
I stumbled upon this problem and it took my a while to realise what
I stumbled upon this while doing a review and the author is not available:
So I stumbled upon this "new" graphics engine/technology called Unlimited Detail . This seems

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.