Convert T-SQL to Lambda

how to convert this query to lambda expression

SELECT *
FROM   T1
WHERE  T1.a = 21
       AND T1.b = 1
       AND T1.c = 0
       AND (T1.d IN (SELECT T2.a
                     FROM   T2
                     WHERE  T2.b = 21
                            AND T2.c = 10251367
                            AND T2.d = 100001000002)
            OR T1.d IN (SELECT (T2.a / 100) * 100
                        FROM   T2
                        WHERE  T2.b = 21
                               AND T2.c = 10251367
                               AND T2.d = 100001000002))

thanks

Answers


Two different ways, one is linq to sql and the other uses extension methods. Like Matten pointed out Select t2a is logical the same as SELECT (t2.a /100) * 100)

ALL BELOW IS PSEUDO CODE SO DO NOT CUT AND PASTE AND EXPECT IT TO WORK.

Linq to Sql

var firstQuery = (From a in context.T2
                     WHERE a.b == 21 AND a.c == 10251367 AND a.d == 100001000002)   


var final = (FROM foo IN context.T1
             where foo.a == 21 
             AND FOO.B == 1 
             AND FOO.C == 0
             and firstQuery.contains(foo.d)

Extension methods

var firstQuery = context.T2.Select.Where( a => a.b == 21 AND a.c == 10251367 AND a.d == 100001000002 )           

var final = context.T1.Select(y => y).Where ( x= > x. a== 21 && x.b = 1 && x.c == 0 and x.d firstQuery.contains(x.d));

Need Your Help

Unable to start activity ComponentInfo android.view.InflateException: Binary XML file line #16

android android-fragments android-emulator

I just want to create an Listview With Images using listfragment in actionbar tab..so here is the error log

How to tell a rightCalloutAccessoryView has been touched for MapKit

iphone iphone-sdk-3.0 mapkit

I have a MKAnnotationView being allocated with a DetailDisclosure button being displayed on the right side of the annotation. How would I go about knowing when a user clicked on the annotation butt...