Dipping my toes into OrmLite and running some unit tests with the in memory sqlite. These two functions should produce same result.
public List<TailRegistration> GetByTailnumber(string tailNumber)
{
return
Db.Select<TailRegistration>(
x => x.TailNumber == tailNumber);
}
public List<TailRegistration> GetByTailnumber2(string tailNumber)
{
return
Db.Select<TailRegistration>(
x => x.TailNumber.Equals(tailNumber));
}
The second function does not work and gives me a “NotSupportedException”. Not sure why .equals doesn’t work. Both sides are strings.
Test method KioskApp.Data.Tests.TailRegistrationsRepositoryTests.GetByTailnumberTest2 threw exception:
System.NotSupportedException: Specified method is not supported.
at ServiceStack.OrmLite.SqlExpression1.VisitColumnAccessMethod(MethodCallExpression m) at ServiceStack.OrmLite.Sqlite.SqliteExpression
1.VisitColumnAccessMethod(MethodCallExpression m)
at ServiceStack.OrmLite.SqlExpression1.VisitMethodCall(MethodCallExpression m) at ServiceStack.OrmLite.SqlExpression
1.Visit(Expression exp)
at ServiceStack.OrmLite.SqlExpression1.VisitLambda(LambdaExpression lambda) at ServiceStack.OrmLite.SqlExpression
1.Visit(Expression exp)
at ServiceStack.OrmLite.SqlExpression1.AppendToWhere(String condition, Expression predicate) at ServiceStack.OrmLite.SqlExpression
1.Where(Expression1 predicate) at ServiceStack.OrmLite.ReadExpressionCommandExtensions.Select[T](IDbCommand dbCmd, Expression
1 predicate)
at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.<>c__DisplayClass14_01.<Select>b__0(IDbCommand dbCmd) at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func
2 filter)
at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.Exec[T](IDbConnection dbConn, Func2 filter) at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.Select[T](IDbConnection dbConn, Expression
1 predicate)
at KioskApp.Data.TailRegistrationsRepository.GetByTailnumber2(String tailNumber) in C:\git\airport-kiosk\KioskApp.Data\TailRegistrationsRepository.cs:line 42
at KioskApp.Data.Tests.TailRegistrationsRepositoryTests.GetByTailnumberTest2() in C:\git\airport-kiosk\Test.KioskApp\TailRegistrationsRepositoryTests.cs:line 167