Left outer join in nhibernate

as.....

vehicle table

id vehicle_id vehicle_Name
1 TN10001 car
2 tires TN100
3 tn4oo van

device table

id device_ID .... Vehicle_id
1 d1 ... 1
2 d2 ... null

I want the vehicle number (tn100, tn4oo) from the table of vehicles that were not listed in the device table (have vehicle identifier Tn10001)

where bidirectional one-to-many mapping is displayed in a vehicle.

+3
source share
1 answer

That should do the trick

var invalidVehicleIds= DetachedCriteria.For(typeof(Device))
.SetProjection(Projections.Id());

Session.CreateCriteria(typeof(Vehicle))
.Add(Subqueries.PropertyNotIn("Id",invalidVehicleIds))
.List<Vehicle>()
+2
source

Source: https://habr.com/ru/post/1781810/


All Articles