Esempio n. 1
0
        public static void UpdateShouldOnlyUpdateOne()
        {
            SqlClientRegistrar.Register <DaoReferenceObject>();
            string             first  = "".RandomString(8);
            string             second = "".RandomString(4);
            DaoReferenceObject test   = new DaoReferenceObject();

            test.BoolProperty   = true;
            test.StringProperty = first;
            Expect.IsTrue(test.IsNew);
            test.Commit();

            DaoReferenceObject one = DaoReferenceObject.OneWhere(f => f.StringProperty == test.StringProperty);

            one.StringProperty = second;

            Expect.IsFalse(one.IsNew);
            one.Commit();

            DaoReferenceObjectCollection results = new DaoReferenceObjectCollection(
                Select <DaoReferenceObjectColumns>
                .From <DaoReferenceObject>()
                .Where(f => f.StringProperty == second));

            Expect.IsTrue(results.Count == 1);
        }
Esempio n. 2
0
        public static void QuerySetShouldFillIHasDataTableList()
        {
            SqlClientRegistrar.Register <DaoReferenceObject>();
            QuerySet testQuerySet = new QuerySet();

            Expect.IsNull(testQuerySet.DataSet);
            DaoReferenceObject test = new DaoReferenceObject();

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

            testQuerySet.Select <DaoReferenceObjectColumns, DaoReferenceObject>(f => f.Id == test.Id);

            DaoReferenceObject dao = new DaoReferenceObject();

            dao.StringProperty = "".RandomString(5);

            testQuerySet.Insert <DaoReferenceObject>(dao);

            testQuerySet.Execute(Db.For <DaoReferenceObject>());

            Expect.IsNotNull(testQuerySet.DataSet);
            Expect.IsTrue(testQuerySet.DataSet.Tables.Count == 2);
            Expect.IsGreaterThan(testQuerySet.Results.Count, 0);
            Expect.AreEqual(2, testQuerySet.Results.Count);

            DaoReferenceObject d = testQuerySet.Results.ToDao <DaoReferenceObject>(1);

            Expect.AreEqual(dao.StringProperty, d.StringProperty);

            DaoReferenceObjectCollection coll = testQuerySet.Results.As <DaoReferenceObjectCollection>(0);

            Expect.IsNotNull(coll);
            Expect.IsGreaterThan(coll.Count, 0);
        }
Esempio n. 3
0
        public static void QuerySetWhereShouldWorkAsExpected()
        {
            SqlClientRegistrar.Register <DaoReferenceObject>();
            DaoReferenceObject test  = Create();
            DaoReferenceObject test2 = Create();

            QuerySet           query = new QuerySet();
            DaoReferenceObject third = new DaoReferenceObject();

            third.StringProperty = test.StringProperty;

            query.Insert(third);
            query.Select <DaoReferenceObject>().Where <DaoReferenceObjectColumns>(c => c.StringProperty == third.StringProperty);


            query.Execute(Db.For <DaoReferenceObject>());

            DaoReferenceObjectCollection coll = query.Results.As <DaoReferenceObjectCollection>(1);

            foreach (DaoReferenceObject obj in coll)
            {
                Out(obj.PropertiesToString());
                Out();
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
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));
        }
Esempio n. 6
0
 public ActionResult Save(Bam.Net.DaoRef.DaoReferenceObject[] values)
 {
     try
     {
         DaoReferenceObjectCollection saver = new DaoReferenceObjectCollection();
         saver.AddRange(values);
         saver.Save();
         return(Json(new { Success = true, Message = "", Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }