I have following sql query
select * from one a
inner join one b
on
(
a.weekday=b.weekday
and a.starttime =b.starttime
and a.sl>b.sl
)
where a.weekday=b.weekday and a.starttime=b.starttime and a.endtime=b.endtime
And I want it to be converted to linq statement both lambda expression and sql-like syntax. i tried but it seems like bit difficult. I have also used a tool like sqltolinq but not seem to be working.
The problem is with sql-like syntax is that my query s join has multiple elements that includes equal
and greater than
operator.
any help will be appreciated
LINQ only supports equijoins, but you could do an equijoin for the weekday and starttime, and endtime parts and then a where clause for the rest.
// Names changed to be more idiomatic where feasible. We have no
// idea what "sl" means.
var query = from a in db.TableA
join b in db.TableB
on new { a.WeekDay, a.StartTime, a.EndTime }
equals new { b.WeekDay, b.StartTime, b.EndTime }
where a.Sl > b.Sl
select ...;
See more on this question at Stackoverflow