I'm trying to figure out why using the LINQ provider produces LEFT
OUTER JOINs for all my associations, but the Criteria API produces
inner joins, using exactly the same mapping with both methods.

The LINQ statement looks like th following:

            var inspections = (from i in
session.Linq<ElevatorInspectionInfo>()
                              where
i.InspectorPermit.Individual.LastName == "Smith"
                              select new
                                         {
                                             i.InspectionID,
                                             i.Elevator.ObjectID,
 
i.Elevator.JurisdictionID,
                                             i.Elevator.JurisNumber,
                                             i.InspectionDate,
                                             LocationName =
i.Location.Name,
 
i.Location.MailingAddress1,
                                             i.Location.MailingCity,
                                             i.Location.MailingState,
                                             i.Location.MailingZip,
                                             InspectorName =
i.InspectorPermit.Individual.LastName + ", " +
i.InspectorPermit.Individual.FirstName
                                         }).Take(10).ToList();

The Criteria query looks like this:

            ICriteria inspectionQuery =
session.CreateCriteria<ElevatorInspectionInfo>("i");

            inspectionQuery.CreateAlias("Location", "l");
            inspectionQuery.CreateAlias("Elevator", "e");

            inspectionQuery.CreateCriteria("InspectorPermit", "ip")
                .CreateCriteria("Individual", "ind")
                .Add(Restrictions.Eq("LastName", "Smith"));


            inspectionQuery.SetProjection(Projections.ProjectionList()
                                              .Add(Projections.Property
("i.InspectionID"))
                                              .Add(Projections.Property
("e.ObjectID"))
                                              .Add(Projections.Property
("e.JurisdictionID"))
                                              .Add(Projections.Property
("e.JurisNumber"))
                                              .Add(Projections.Property
("i.InspectionDate"))
                                              .Add(Projections.Property
("l.Name"))
                                              .Add(Projections.Property
("l.MailingAddress1"))
                                              .Add(Projections.Property
("l.MailingCity"))
                                              .Add(Projections.Property
("l.MailingState"))
                                              .Add(Projections.Property
("l.MailingZip"))
                                              .Add(Projections.Property
("ind.FirstName"))
                                              .Add(Projections.Property
("ind.LastName"))
                                           ).SetResultTransformer
(Transformers.AliasToEntityMap);

            inspectionQuery.SetMaxResults(10);

            var result = inspectionQuery.List<IDictionary>();

These look like they should produce roughly the same query.  And they
do, aside from the type of join used.  I would really prefer to use an
inner join, is there any way to get the LINQ provider to do that?

Thanks!
Brian
-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhus...@googlegroups.com.
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to