I have the following method:
var catIds = DetachedCriteria.For<Category>()
.Add<Category>(c => c.TypeCode == "IMA")
.SetProjection(LambdaProjection.Property<Category>(s => s.Id));
This is returning nothing because in the database the field is nchar(10)
. I want to Trim()
the TypeCode value, as follows:
var catIds = DetachedCriteria.For<Category>()
.Add<Category>(c => c.TypeCode.Trim() == "IMA")
.SetProjection(LambdaProjection.Property<Category>(s => s.Id));
but it returns the NHibernate error:
Unrecognised method call in epression c.TypeCode.Trim()
One of the guys here in the office thinks it's because HHibernate doesn't know how to convert .Trim()
to SQL (or something along those lines). Can anyone suggest how I can fix this?