Friday, 15 June 2012

c# - Subquery help in LINQ -



c# - Subquery help in LINQ -

hi can help me how write below query in linq i'm new linq

select * employee employeeid = 'e101' or empdept = (select dept departments deptid = 'd101')

thanks in advance

you can utilize grouping join

from e in employee bring together d in deparment.where(x => x.deptid == "d101") on e.empdept equals d.dept g e.employeeid == "e101" || g.any() select e;

that generates next sql

declare @p0 nvarchar(1000) = 'e101' declare @p1 nvarchar(1000) = 'd101' select * [employee] [t0] ([t0].[employeeid] = @p0) or (exists( select null [empty] [deparment] [t1] ([t0].[empdept] = [t1].[dept]) , ([t1].[deptid] = @p1) ))

c# sql linq subquery

No comments:

Post a Comment