示例#1
0
        private static MainObject CreateFromFilter(IQueryFilter filter, Database database = null)
        {
            Database db  = database ?? Db.For <MainObject>();
            var      dao = new MainObject();

            filter.Parameters.Each(p =>
            {
                dao.Property(p.ColumnName, p.Value);
            });
            dao.Save(db);
            return(dao);
        }
示例#2
0
        public void ShouldBeAbleToSetValuesFromQueryFilter()
        {
            SQLiteDatabase testDatabase = GetTestDatabase();
            string         testName     = 8.RandomLetters();
            QueryFilter    filter       = Query.Where("Name") == testName;
            MainObject     one          = MainObject.OneWhere(filter, testDatabase);

            Expect.IsNull(one);
            if (one == null)
            {
                one = new MainObject();
                filter.Parameters.Each(p =>
                {
                    one.Property(p.ColumnName, p.Value);
                });
                one.Save(testDatabase);
            }

            MainObject check = MainObject.OneWhere(filter, testDatabase);

            Expect.IsNotNull(check);
            OutLine(check.TryPropertiesToString());
        }