My LINQ query joins two tables in EF 4.1, but when I look at the SQL Profiler, it just does a basic select from only one of the tables. The join is ignored. I've tried many variations on the LINQ query, but get the same result. The odd thing is that inner joins work elsewhere in my app. I can't make any sense out of it. I'm close to giving up and just calling a stored procedure but would pre开发者_如何学运维fer not to. Here are some examples of what I tried:
Note that SQL Profiler always gives me: SELECT * FROM Protocols
.
from s in db.Staff
join p in db.Protocols on s.ID equals p.PIID
select p
from s in db.Staff
from p in db.Protocols
where p.PIID == s.ID
select p
from s in db.Staff
from p in db.Protocols
where p.PIID == s.ID && s.ID = 99
select p
If I do select s
at the end, the the Staff
table does get included, but this is obviously not what I want b/c I need the data from the protocol table.
精彩评论