开发者

left outer join in nhibernate

开发者 https://www.devze.com 2023-01-31 18:23 出处:网络
like..... vehicle table id vehicle_id vehicle_Name 1TN10001car 2TN100bus 3tn4oovan device table id device_ID .... Vehicle_id

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 i开发者_StackOverflow社区s mapped in vehicle.


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>()
0

精彩评论

暂无评论...
验证码 换一张
取 消