Saturday 15 August 2015

NHibernate Criteria, select by count of property -


Sorry for the secret title ..

Can you help me, how to make a selection Based on a property count using criteria? I have an item with a pool, and I want to select all the pools. More than 5 pooled elements

Try it out:

  isolated order dCriteria = Isolated Cerebrum For & lt; PoolItem & gt; ("PITIM"). Add STO Projection (Projection.Count ("ID")). (Restriction. EProperty ("PITIM. Police ID", "Pool.ID")); IList & LT; Post & gt; Positions = session. Creatitivity & lt; Pool & gt; ("Pool"). Add (Subcategories GT (5, DCRTERIA)) List & lt; Pool & gt; ();  

Assuming the PoolItem table, the PoolID column is in the form of the foreign key of the pool table. Relationship is multiple-by-one If you do not have a pool ID property in the poolITIT category and you have multiple-to-one object mapping named "pool", then "pItem.PoolID" with "pItem.Pool.Id" Change to different criteria.


No comments:

Post a Comment