Exemplo n.º 1
0
        public static void WhereShortCutShouldWork()
        {
            SqlClientRegistrar.Register(Db.For <DaoReferenceObject>().ServiceProvider);

            DaoReferenceObject test = new DaoReferenceObject();

            test.StringProperty = "".RandomString(8);
            test.Commit();

            DaoReferenceObjectCollection checking = DaoReferenceObject.Where(c => c.StringProperty == test.StringProperty);

            Expect.IsTrue(checking.Count == 1);
        }
Exemplo n.º 2
0
        public static void ShortcutShouldWorkLikeLongcut()
        {
            SqlClientRegistrar.Register(Db.For <DaoReferenceObject>().ServiceProvider);

            DaoReferenceObject test = new DaoReferenceObject();
            string             val  = "".RandomString(8);

            test.StringProperty = val;
            test.Commit();
            DaoReferenceObjectCollection results = DaoReferenceObject.Where(f => f.Id == test.Id);

            Expect.IsTrue(results.Count > 0);
            Expect.IsTrue(results[0].StringProperty.Equals(val));
        }
Exemplo n.º 3
0
        public void CanQueryByUlongProperty()
        {
            Database db = new SQLiteDatabase(nameof(SaveAndQueryTest));

            db.TryEnsureSchema <DaoReferenceObject>();
            DaoReferenceObject.LoadAll(db).Delete(db);
            ulong testValue = 8374384738473847;

            DaoReferenceObject referenceObject = new DaoReferenceObject()
            {
                IntProperty       = 10,
                DecimalProperty   = 10,
                LongProperty      = 10,
                ULongProperty     = testValue,
                DateTimeProperty  = Instant.Now,
                BoolProperty      = true,
                ByteArrayProperty = "This is the byte array property".ToBytes(),
                StringProperty    = "This is the string property"
            };

            referenceObject.Id.ShouldBeNull("Id should have been null");
            referenceObject.Save(db);
            string referenceJson = referenceObject.ToJsonSafe().ToJson();

            referenceObject.Id.ShouldNotBeNull("Id should not have been null");

            DaoReferenceObject[] retrieved = DaoReferenceObject.Where(c => c.ULongProperty == testValue, db).ToArray();
            Expect.AreEqual(1, retrieved.Length);
            DaoReferenceObject instance = retrieved[0];

            Expect.AreEqual(instance.ULongProperty, referenceObject.ULongProperty);
            Expect.AreEqual(referenceObject, instance);
            Expect.AreEqual(referenceJson, instance.ToJsonSafe().ToJson());
            Expect.AreEqual(testValue, instance.ULongProperty);

            Message.PrintLine(db.ConnectionString);
        }
Exemplo n.º 4
0
 public object[] Where(QiQuery query)
 {
     return(DaoReferenceObject.Where(query).ToJsonSafe());
 }