Thanks Sergey.
I ended up using a cusor to do the paging on the server side.
Unfortunately, I could not really figure out a generic solution but since I only need paging for one specific case, that ought to be enough.
Here is what I use, if it`s useful for anyone:
Code:
string query = @"
SET NOCOUNT ON
DECLARE mensagens SCROLL CURSOR
FOR " + queryStr2 + @"
FOR READ ONLY
OPEN mensagens
DECLARE @v_counter int
set @v_counter = 0
SELECT *
INTO #temptable
FROM " + tableName + @"
WHERE 1=0
DECLARE @c1 int
DECLARE @c2 datetime
DECLARE @c3 varchar(11)
DECLARE @c4 char(10)
DECLARE @c5 int
DECLARE @c6 varchar(200)
DECLARE @c7 varchar(50)
FETCH ABSOLUTE "+ (pager.MaxPageSize*(pager.CurrentPageNumber-1) + 1) +@" FROM mensagens INTO @c1,@c2,@c3,@c4,@c5,@c6,@c7
WHILE (@v_counter < "+ (pager.MaxPageSize-1) + @" AND @@FETCH_STATUS = 0)
BEGIN
INSERT #temptable SELECT @c1,@c2,@c3,@c4,@c5,@c6,@c7
FETCH next FROM mensagens INTO @c1,@c2,@c3,@c4,@c5,@c6,@c7
SET @v_counter = @v_counter + 1
END
SELECT * FROM #temptable
I have to create a IDbCommand and execute the query, and manually populate my objects (didn't try to use CreateSQLQuery since I read it's not functional yet, is that true?)
As you can see, I could not find out how to avoid specifying the specific column types. Do you know of a more generic way to achieve this?
I also had to manually create a SQL query. Is there any way to get SQL from HQL? I know it might yield more than one sql query, but it shouldn't in my case.
I am also having difficulties in extracting column and table names from class and property names. Couldn't really find the key properties in the Configuration object...
Any comments are welcome :)