Nhibernate syntax problem?
Well i am rather new to nhibrenate syntax and need desperately your help.
I have a table called Cookie with the following attributes:
Id(int) , Datetime(datetime), UniqueId (string) , IsTransaction(bool)
All i want is to produce a list of the above table like this
Id Datetime UniqueId IsTransaction
25/8/2011 789 1
23/8/2011 789 0
22/8/2011 789 0
20/8/2011 789 0
20/8/2011 789 0
20/8/2011 789 1
19/8/2011 789 0
18/8/2011 789 开发者_StackOverflow社区 0
25/8/2011 111 1
24/8/2011 111 0
23/8/2011 111 0
20/8/2011 111 0
17/8/2011 111 0
15/8/2011 111 1
13/8/2011 111 0
12/8/2011 111 0
11/8/2011 111 0
10/8/2011 111 0
To be honest i find it difficult do write that query even in plain SQL :(
Any ideas??
Thanks!
session.CreateQuery("from Cookie").List();
//optionally you can add the where condition like this
session.CreateQuery("from Cookie where IsTransaction=1").List();
Both the above code is in HQL or you can use SQL as follows:
session.CreateSQLQuery("select * from Cookie");
//optionally you can add the where condition like this
session.CreateSQLQuery("select * from Cookie where IsTransaction=1").List();
instead of the * you could give your column names too if you want to select only a few columns.. I dont know why your Id field is empty..
精彩评论