Пример #1
0
        private QueryBuilderParms QueryBuilderParmsForThisCritera(CriteriaDto criteriaDto,
                                                                  SchemaRepository schemaRepository, QueryBuilderParms queryBuilderParms)
        {
            queryBuilderParms.PrimaryTable = criteriaDto.TableName;
            if (IsNullOrEmpty(criteriaDto.CompareOperator))
            {
                return(queryBuilderParms);
            }
            var colDataType =
                schemaRepository.GetSchemaTableColumns(criteriaDto.TableColumn)
                .MetaData.Select(x => x.DbType)
                .ToString();

            queryBuilderParms.WhereConditionsList = new List <WhereCondition>
            {
                new WhereCondition
                {
                    WhereLeftColumn  = criteriaDto.TableColumn.Replace($"{criteriaDto.TableName}.", ""),
                    WhereLeftTable   = $"dbo.{criteriaDto.TableName}",
                    WhereOperator    = GetComparison(criteriaDto.CompareOperator), // Comparison.Equals,
                    WhereRightColumn = FixQuotes(colDataType, criteriaDto.CompareValue)
                }
            };
            return(queryBuilderParms);
        }
Пример #2
0
        private void AddWhereClauseToCurrentQuery(CriteriaDto criteriaDto, QueryBuilderParms queryBuilderParms,
                                                  SchemaRepository schemaRepository)
        {
            var colDataType =
                schemaRepository.GetSchemaTableColumns(criteriaDto.TableColumn)
                .MetaData.Select(x => x.DbType)
                .ToString();

            queryBuilderParms.WhereConditionsList.Add(new WhereCondition
            {
                WhereLeftColumn  = criteriaDto.TableColumn.Replace($"{criteriaDto.TableName}.", ""),
                WhereLeftTable   = $"dbo.{criteriaDto.TableName}",
                WhereOperator    = GetComparison(criteriaDto.CompareOperator),
                WhereRightColumn = FixQuotes(colDataType, criteriaDto.CompareValue)
            });
        }
Пример #3
0
        public string CreateNextCriteriaForQuery(O2CV1QueryDto queryDto, CriteriaDto criteriaDto)
        {
            var criteriaRepository = new CriteriaRepository(_dbConnectionString);

            if (criteriaRepository.DoesQueryExist(queryDto.QueryName))
            {
                var currentCountCriteria =
                    criteriaRepository.GetCountOfCriteriaForQuery(Convert.ToInt64(queryDto.QueryId));
                criteriaDto.Sequence = currentCountCriteria += 1;
                criteriaRepository.AddCriteriaToQuery(queryDto, criteriaDto);
            }
            else
            {
                criteriaRepository.AddQueryAndFirstCriteriaToQuery(queryDto, criteriaDto);
            }

            return(criteriaRepository.GetIdOfQuery(queryDto.QueryName));
        }