I have a table with 10,000 items.
IQuerable<IEntity> query = dataRep.Get<IEntity>()
.Query();
I need to get the index (rownum) of the selected one objwithout getting all the table elements
var obj = query.Where( x => x.Name == "testName")
.FirstOrDefault();
Simple sql execution:
select name, id, r from
(
select name, id, rownum r from collections order by id
) where name = 'testName';
How to do it in Linq for NHibernate?
Edit:
I tried adding IEntityclass to the property RowNumberand mapping it to hbmhow
<property name="RowNumber" formula="rownum" />
But after
var index = query.Where( x => x.Name == "testName")
.Select( x => x.RowNumber)
.FirstOrDefault();
Always get 1value
source
share