Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Monday 5 December 2011

NHibernate : Arithmetic overflow error converting expression to data type int

As mentioned in SQL Server Error : Arithmetic overflow error converting expression to data type int article to use cast() in sql to correctly typecast for large numbers, Now this can be achieved using NHibernate & Fluent Hibernate as per the snippet below:-

 var criteria = session.CreateCriteria();
 criteria.SetProjection(Projections.ProjectionList()
 .Add(Projections.Count("ID").As("ID"))
 .Add(Projections.Sum(Projections.Cast(NHibernateUtil.Int64, Projections.Property("imagesize "))).As("TotalSize")))      
.SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(ImagesSummary)));
ImagesSummary summary = (ImagesSummary)criteria.UniqueResult();

I regularly read Internet user groups filled with messages from people trying to solve software incompatibility problems that, in terms of complexity, make the U.S. Tax Code look like Dr. Seuss. ~Dave Barry

1 comments:

Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers