public static void FilterOrExpression() { Database database = new SQLiteDatabase(".\\", MethodBase.GetCurrentMethod().Name); ConsoleLogger logger = PrepareDatabaseAndGetLogger(database); TestTable one = new TestTable(); one.Name = "banana"; one.Save(database); TestTable two = new TestTable(); two.Name = "blah"; two.Save(database); DaoExpressionFilter v = new DaoExpressionFilter(logger); QueryFilter testFilter = v.Where <TestTable>((t) => t.Name == one.Name).Or <TestTable>((t) => t.Name == two.Name); TestTableCollection check = TestTable.Where(c => c.Name == "banana" || c.Name == "blah", database); Expect.IsNotNull(check); TestTableCollection evalCheck = TestTable.Where(testFilter, database); Expect.IsNotNull(evalCheck); Expect.AreEqual(2, evalCheck.Count); Out(v.TraceLog, ConsoleColor.Cyan); }
public static void DaoExpressionFilterTest() { SQLiteBitMonitor.MonitorBitness(); Database database = new SQLiteDatabase(".\\", MethodBase.GetCurrentMethod().Name); ConsoleLogger logger = PrepareDatabaseAndGetLogger(database); TestTable testInstance = new TestTable(); testInstance.Name = "banana"; testInstance.Save(database); DaoExpressionFilter v = new DaoExpressionFilter(logger); QueryFilter testFilter = v.Where <TestTable>((t) => t.Name == testInstance.Name); TestTable check = TestTable.Where(Filter.Column("Name") == "banana", database).FirstOrDefault(); Expect.IsNotNull(check); TestTable evalCheck = TestTable.Where(testFilter, database).FirstOrDefault(); Expect.IsNotNull(evalCheck); Expect.AreEqual(check.Id, evalCheck.Id); Out(v.TraceLog, ConsoleColor.Cyan); }
public static void ConditionalExpressionThrowsException() { Database database = new SQLiteDatabase(".\\", MethodBase.GetCurrentMethod().Name); ConsoleLogger logger = PrepareDatabaseAndGetLogger(database); DaoExpressionFilter f = new DaoExpressionFilter(logger); bool thrown = false; try { Out(f.Where <TestTable>((t) => t.Name == "blah" || t.Name == "monkey").Parse(), ConsoleColor.DarkCyan); } catch (ExpressionTypeNotSupportedException etnse) { thrown = true; Out(etnse.Message, ConsoleColor.Cyan); } Expect.IsTrue(thrown); }
public IEnumerable <T> Query <T>(Expression <Func <T, bool> > expression) where T : class, new() { DaoExpressionFilter expressionFilter = new DaoExpressionFilter(Logger); return(Query <T>(expressionFilter.Where <T>(expression))); }