string comparison parameter in the where clause is not being passed into the generated SQL after a previous execution with 'null' as the parameter value

Description

IList<Person> FindPerson(string id)
{
return (from obj in mySession.AsQueryable<Person>() where obj.ID==id select obj).ToList();
}

This sequence runs fine:
FindPerson("0001"); //correctly returns person with id 0001
FindPerson(null); // correctly returns null
FindPerson("0002"); //correctly returns person with id 0002

This sequence doesn't run fine:
FindPerson(null); // correctly returns null
FindPerson("0001"); // incorrectly returns null. In the generated SQL where clause there is only a IS NULL and the criteria '0001' is not there

Environment

None

Activity

Show:

Joseph Lam 
November 22, 2010 at 5:18 AM

My DB table:
CREATE TABLE [dbo].[Person](
[UUID] [nvarchar](255) NOT NULL,
[DateOfBirth] [datetime] NULL,
[SocialInsuranceNumber] [nvarchar](255) NULL,
[OACountryCode] [nvarchar](255) NULL,
[IsMarkDeleted] [bit] NULL,
[TimeMarkDeleted] [datetimeoffset](7) NULL,
[Gender_id] [nvarchar](255) NULL,
[Citizenship_id] [nvarchar](255) NULL,
[MaritalStatus_id] [nvarchar](255) NULL,
[ContactProfile_id] [nvarchar](255) NULL,
[KycStatus_id] [nvarchar](255) NULL,
[RealNameFirstName] [nvarchar](255) NULL,
[RealNameMiddleName] [nvarchar](255) NULL,
[RealNameLastName] [nvarchar](255) NULL,
[Application_id] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED
(
[UUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

Joseph Lam 
November 21, 2010 at 2:30 PM

found a workaround: use obj.ID.Equals(id) instead of ==

Joseph Lam 
November 21, 2010 at 2:28 PM

I'm using NHibernate 3 latest binaries

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created November 21, 2010 at 2:27 PM
Updated November 22, 2010 at 5:18 AM
Who's Looking?