var parent_child = entities.Parent.Join
(
entities.Child, // child entity
parent => parent.ParentId, // function providing parent key
child => child.ChildId, // function providing child key
( parent, child ) => new // projection (anonymous object returning what you want)
{
ChildId = child.ChildId,
WhateverElseFromChild = child.WhateverElse,
WhateverElseFromParent = parent.WhateverElse,
ParentId = parent.ParentId
}
// pc here is anonymous object created above
).Where( pc => pc.Condition == "some condition" ).FirstOrDefault();
Tracing this against SqlServer showed very clean SQL. The exact same SQL produced by this linq equivalent:
var parent_child = ( from parent in entities.Parent
join child in entities.Child on parent.ParentId equals child.ChildId
where parent.Condition == "some condition"
select new
{
ChildId = child.ChildId,
WhateverElseFromChild = child.WhateverElse,
WhateverElseFromParent = parent.WhateverElse,
ParentId = parent.ParentId
}).FirstOrDefault();