views:

314

answers:

0

I need a DataRow with every column of a table T without the column Y, which holds the primary key.

The SQL is:

SELECT * FROM T WHERE Y=N LIMIT 1

"LIMIT 1" is a mysql dialect so that is the reason I need an agnostic ISQLQuery (query.SetMaxResults(1);) to do the work.

I can get a row in the form of object[] using this code:

ISQLQuery query = session.CreateSQLQuery("SELECT * FROM " + T + " WHERE " + _Y+ "=?");
query.SetInt32(0, id);
query.SetMaxResults(1);
return query.UniqueResult<object[]>();

But doing this way, I cant get the column's name which I need, among other things, to discard the Y column from the result.

Hence I need to get a DataRow for that purpose. Is it posible to get the native SQL from the query without executing it so I can execute a dbcommand with it and get the desired DataRow? Is any other solution to get a DataRow?