Reputation: 291
how do i change this to linq to sql?
select * from ratesSchedule as rs
inner join userdetails as ud on rs.sid = ud.sid
and rs.tabletype = 'd'
i got this far
var results = from rs in db.ratesSchedule
join ud in db.userdetails on rs.sid equals ud.sid
but i can't figure out how to add the "and rs.tabletype='d'"
Upvotes: 1
Views: 7456
Reputation: 238136
If you'd like to do it without where clause, try this:
var results = from rs in db.ratesSchedule
join ud in db.userdetails on
new { rs.sid, rs.tabletype } equals
new { ud.sid, tabletype = "d" }
Personally I'd stick to SQL in this case, since LINQ isn't even easier to read. ;)
Upvotes: 5
Reputation: 74540
You should be able to just put it in the WHERE part of the statement, since you aren't joining on a condition other than a comparison to a constant field on the table:
var results = from rs in db.ratesSchedule
join ud in db.userdetails on rs.sid equals ud.sid
where rs.tabletype = 'd'
Upvotes: 3