public void TestConditionWhereString() { var sqlRaw = "select * from test"; var nsql = new NSQLQuery(sqlRaw); var texto = "nome do cliente"; nsql.Where("coluna1", Op.IGUAL, texto); nsql.Where("coluna2", Op.Diferente, texto); Assert.AreEqual(nsql.ToSql(), sqlRaw + " WHERE coluna1 = 'nome do cliente' AND coluna2 != 'nome do cliente'", true); }
public void TestConditionWHereNull() { var sqlRaw = "select * from test"; var nsql = new NSQLQuery(sqlRaw); nsql.Where("coluna1", Op.Null); var expected = "select * from test where coluna1 is null"; Assert.AreEqual(expected, nsql.ToSql(), true); }
public void TestConditionWhereNumber() { var sqlRaw = "select * from test"; var nsql = new NSQLQuery(sqlRaw); var valor = 10; nsql.Where("coluna1", Op.IGUAL, valor); Assert.AreEqual(nsql.ToSql(), sqlRaw + " WHERE coluna1 = 10", true); }
public void TestConditionWhereSubCondition() { var sqlRaw = "select * from test"; var nsql = new NSQLQuery(sqlRaw); nsql.Where("coluna2", Op.IGUAL, "teste").Where(x => { x.Where("coluna1", Op.IGUAL, "teste"); }); var expected = "select * from test WHERE coluna2 = 'teste' AND ( coluna1 = 'teste' )"; Assert.AreEqual(expected, nsql.ToSql(), true); }
public void TestConditionWhereOr() { var sqlRaw = "select * from test"; var nsql = new NSQLQuery(sqlRaw); var numero = 10; nsql.Where("coluna1", Op.IGUAL, numero); nsql.WhereOr("coluna2", Op.Diferente, numero); var expected = sqlRaw + " WHERE coluna1 = 10 OR coluna2 != 10"; Assert.AreEqual(expected, nsql.ToSql(), true); }
public void TestConditionWhereJoinWhere() { // Query Principal var sqlRaw = "select * from test"; var nsql = new NSQLQuery(sqlRaw); // Query 2 var nSubSql = new NSQLQuery(); nSubSql.Where("coluna1", Op.IGUAL, "TESTE"); // Adiciona sub query nsql.JoinWhere(nSubSql); var expected = "select * from test WHERE coluna1 = 'TESTE'"; Assert.AreEqual(expected, nsql.ToSql(), true); }