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.
sqlfiddle here