I have a table with a Name field containing data similar to the following:
a1
a2
b1
c1
1a
1b
2a
9b
I'm trying to select only the rows values that start with a number.
I'm trying to do this with the following query, but it doesn't work:
var numberGroups = _session
.CreateCriteria<CompanyGroupInfo>()
.Add(SqlExpression.Between<CompanyGroupInfo>(g => int.Parse(g.Name.Substring(0, 1)), 0, 9))
.List<CompanyGroupInfo>();
It's throwing the error:
Unrecognised method call in epression Parse(g.Name.Substring(0, 1))
note the 'expression' typo - that's NHibernate, not me :-)
Can somebody suggest how I can achieve the result I'm looking for? Thanks
edit: I tried Jon's suggestions below, as well as SqlExpression.Not<CompanyGroupInfo>(g => !char.IsLetter(g.Name.Substring(0, 1).ToCharArray()[0]))
but they all throw similar errors to what I've posted above.