YJingLee,

Ok no problem. :)

thanks for your reply.

On 28 Ağustos, 17:08, YJingLee <[email protected]> wrote:
> sorry ,I ignore it
>
> On Aug 28, 9:34 pm, Fabio Maulo <[email protected]> wrote:
>
>
>
> > .SetString("fn", employeeId.ToString()) ??mmm that smell wrong
>
> > this smell better
> > .SetInt32("fn", employeeId)
>
> > 2009/8/28 YJingLee <[email protected]>
>
> > > int64 count = (int64)session.CreateQuery("select count(*) from
> > > Employees where EmployeeID = :fn")
> > >                .SetString("fn", employeeId.ToString())
> > >                .UniqueResult();
>
> > > On Aug 28, 7:54 pm, İlgiz Seber <[email protected]> wrote:
> > > > Hi,
>
> > > > I found a trick about casting Count() to int result on this link:
> > >http://nhforge.org/doc/nh/en/index.html#queryhql-tipstricks
>
> > > > Then i wrote a HQL like this:
>
> > > > public int HQL_GetCustomerCount(int employeeId)
> > > >         {
> > > >             int count = (int)session.CreateQuery("select count(*) from
> > > > Employees where EmployeeID = :fn")
> > > >                 .SetString("fn", employeeId.ToString())
> > > >                 .UniqueResult();
>
> > > >             return count;
> > > >         }
>
> > > > And also i wrote a test fot it too:
>
> > > >  [Test]
> > > >         public void HQL_CanGetCustomerCount()
> > > >         {
> > > >             int count = dataProvider.HQL_GetCustomerCount(1);
>
> > > >             Assert.AreEqual(1, count);
> > > >         }
>
> > > > Then i run my test expecting to cast count() result to int according
> > > > to the trick, i got this exception:
>
> > > > "NHibernateDataProviderTest.HQL_CanGetCustomerCount : Failed
>
> > > > NHibernate: select count(*) as col_0_0_ from Employees employees0_
> > > > where employees0_.employee...@p0;@p0 = '1'
>
> > > > System.InvalidCastException: Specified cast is not valid."
>
> > > > Is it a bug or am i making a terrible mistake?
>
> > > > NOTE: I am using NHibernate 2.1.0.4000 version. And working on
> > > > Northwind db.
>
> > > > Thanks to everyone.
>
> > --
> > Fabio Maulo- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to