Пример #1
0
        public void DeleteConnection(int id)
        {
            DeleteQuery query = QueryBuilder.Delete(TABLE);

            ((DeleteQuery)query).AddWhereFragment(id);

            var cmd = db.GetCommand(query.Build());

            cmd.ExecuteNonQuery();
        }
Пример #2
0
        public void TestGenerateDeleteWithID()
        {
            var         schemeName    = TestingTools.RandomString;
            var         tableName     = TestingTools.RandomString;
            var         propertyName  = TestingTools.RandomString;
            var         propertyValue = TestingTools.RandomString;
            var         id            = TestingTools.RandomInt;
            DeleteQuery query         = new DeleteQuery(schemeName, tableName);

            query.AddWhereFragment(id);

            var result = query.Build();

            var expected = String.Format("DELETE FROM \"{0}\".\"{1}\" WHERE \"ID\"={2};",
                                         schemeName, tableName, id);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result);
        }
Пример #3
0
        public void TestGenerateDeleteWithWhere()
        {
            var         schemeName    = TestingTools.RandomString;
            var         tableName     = TestingTools.RandomString;
            var         propertyName  = TestingTools.RandomString;
            var         propertyValue = TestingTools.RandomString;
            var         id            = TestingTools.RandomInt;
            DeleteQuery query         = new DeleteQuery(schemeName, tableName);

            Expression <Func <ConnectionDM, bool> > exp = (item) => item.ChildID == id;

            query.AddWhereFragment((BinaryExpression)exp.Body);

            var result = query.Build();

            var expected = String.Format("DELETE FROM \"{0}\".\"{1}\" WHERE \"ChildID\" = '{2}';",
                                         schemeName, tableName, id);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result);
        }