public void Igual_UnSoloAtributo() { string esperado = "(IdTema = 1)"; var wrapper = new WrapperExpression("IdTema", Operators.Equals, 1); string where = wrapper.ToWhereClause(); Assert.AreEqual(esperado, where); }
public void NotContains_UnSoloAtributo() { string esperado = "((IdTema NOT LIKE '%34' OR IdTema NOT LIKE '%34%' OR IdTema NOT LIKE '34%'))"; var wrapper = new WrapperExpression("IdTema", Operators.ContainsNot, "34"); string where = wrapper.ToWhereClause(); Assert.AreEqual(esperado, where); }
public void NotIn_UnSoloAtributo() { string esperado = "(IdTema NOT IN (1,2,4,5))"; var wrapper = new WrapperExpression("IdTema", Operators.NotIn, new List <int> { 1, 2, 4, 5 }); string where = wrapper.ToWhereClause(); Assert.AreEqual(esperado, where); }
public void In_Texto_UnSoloAtributo() { string esperado = "(IdTema IN ('Rojo','Verde','Blanco','Azul'))"; var wrapper = new WrapperExpression("IdTema", Operators.In, new List <string> { "Rojo", "Verde", "Blanco", "Azul" }); string where = wrapper.ToWhereClause(); Assert.AreEqual(esperado, where); }
public virtual async Task <IEnumerable <T> > FindAsync(WrapperExpression predicate) { List <T> items = new List <T>(); try { InitConnection(); string selectQuery = $"SELECT {SelectClause} FROM {FromClause} WHERE {predicate.ToWhereClause()}"; selectQuery += !string.IsNullOrEmpty(OrderByClause) ? $" ORDER BY {OrderByClause}" : String.Empty; var result = await Connection.QueryAsync <T>(selectQuery, commandType : CommandType.Text); return(result.ToList()); } catch (Exception e) { HasError = true; ErrorMessage = e.Message; } finally { FinalizeConnection(); } return(items); }