开发者

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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜