Exemplo n.º 1
0
        public void SqlServerDeleteQuery_ShouldGenQuery()
        {
            // Arrange
            var command = new System.Data.SqlClient.SqlCommand();
            var where = new WhereBuilder<Person>(command, p => p.ID == 5, false);
            IQuery query = new DeleteQuery("dbo.People", where.ToString());

            // Act
            string queryText = query.Generate();

            // Assert
            Assert.IsNotNull(queryText);
            Assert.IsTrue(queryText.Contains("DELETE FROM dbo.People"));
            Assert.IsTrue(queryText.Contains("WHERE ([ID] = @P0)"));
            Assert.AreEqual(command.Parameters["@P0"].Value, 5);
        }
Exemplo n.º 2
0
        public void SqlServerDeleteQuery_ShouldGenQuery()
        {
            // Arrange
            var command = new System.Data.SqlClient.SqlCommand();
            TableCollection tables = new TableCollection { new Table(typeof(Person)) };
            Expression<Func<Person, bool>> filter = p => p.ID == 5;
            var where = new WhereBuilder<Person>(command, new SqlServerDialect(), filter, tables, false, false);
            IQuery query = new DeleteQuery(new Dialect(), tables[0], where.ToString());

            // Act
            string queryText = query.Generate();

            // Assert
            Assert.IsNotNull(queryText);
            Assert.IsTrue(queryText.Contains("DELETE FROM [PersonTable]"));
            Assert.IsTrue(queryText.Contains("WHERE ([ID] = @P0)"));
            Assert.AreEqual(command.Parameters["@P0"].Value, 5);
        }