I did a little work on the entity infrastructure provider and looked at that. I believe that the provider itself has no choice in the situation. The command tree is created by the entity infrastructure and provides the SQL assembly to the provider. This is a complete hunch here, but perhaps the reason it generates the LEFT OUTER join in this situation is because the entity infrastructure really does not know that the reference constraint exists in the database. For example, I can go in and drop the entity model after creating it from the database and add / change constraints that have no idea what the database does. Perhaps for this reason, the designers decided to play safely and create LEFT OUTER, "just in case."
However, I believe you can get an inner join. For example, the following led the provider to create a LEFT OUTER connection:
var res2 = from a in ent.answers select new { a.Answer1, a.user.UserName };
However, the following results are in the INNER compound:
res2 = from a in ent.answers join u in ent.users on a.UserID equals u.PK select new { a.Answer1, u.UserName };
In addition, the following SQL object created an internal join:
ObjectQuery<DbDataRecord> dr = ent.CreateQuery<DbDataRecord>( "SELECT a.answer1, u.username " + "FROM answers as a inner join users as u on a.userid = u.pk" );
Mark wilkins
source share