?
Solved

nhibernate, ICriteria

Posted on 2011-05-11
3
Medium Priority
?
364 Views
Last Modified: 2012-05-11
Hi, I am using nhibernate in my web application to interact with my SQL Server database.
and using ICriteria to extract records from the database.
My question is, can I use ICriteria just to extract a single value(eg: Max(Column name)) from database and how can I store it in an integer variable?
Till now, I have been using ICriteria only with IList , but don't know how can I use it to return a single value from the database.
Could someone please help?
0
Comment
Question by:Tina_Bhole
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
cubaman_24 earned 500 total points
ID: 35738500
Hello:
it would be something like this.
Best regards.
ICriteria criteria = GetBasicCriteria();
criteria.SetProjection(Projections.Max("MyValue"));
return criteria.UniqueResult<int>();

Open in new window

0
 

Author Comment

by:Tina_Bhole
ID: 35742776
Thanks for your reply cubaman. I am getting following error on Projections keyword.

'The name Projection does not exist in current context.

Am I missing any reference in my project?
0
 

Author Comment

by:Tina_Bhole
ID: 35742863
Oh, I figured it out.
I included the reference: NHibernate.Criterion;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question