Ejemplo n.º 1
0
        public void WhenCallAndMethodShouldAddAndCriteriaToQuery()
        {
            const string name   = "Nicolas";
            const int    active = 1;

            _selectQueryBuilder.Select("User");
            _selectQueryBuilder.Where($"Name = {name}");
            _selectQueryBuilder.And($"Active = {active}");
            _selectQueryBuilder.ShowQuery()
            .Should()
            .Be($"SELECT * FROM User WHERE Name = {name} AND Active = {active}");
        }
Ejemplo n.º 2
0
        private void AddWhereClauses()
        {
            foreach (var select in Selects)
            {
                if (!string.IsNullOrWhiteSpace(select.CompareValue))
                {
                    WhereClause where;

                    if (selectQueryBuilder.WhereClauses.Any())
                    {
                        where = selectQueryBuilder.And(select.ColumnName);
                    }
                    else
                    {
                        where = selectQueryBuilder.Where(select.ColumnName);
                    }

                    selectQueryBuilder = AddClause(where, select.CompareType, select.CompareValue) as SelectQueryBuilder;
                }
            }
        }