rajiv
rajiv

Reputation: 33

left outer join in nhibernate

like.....

vehicle table

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

device table

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

i want vehicleid's(tn100,tn4oo) from vehicle table which r not in device table( have vehicle id Tn10001 )

where bi directional one to many mapping is mapped in vehicle.

Upvotes: 3

Views: 453

Answers (1)

Baz1nga
Baz1nga

Reputation: 15579

This should do the trick

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

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

Upvotes: 2

Related Questions