コード例 #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
ファイル: HomeController.cs プロジェクト: lvwf1/o2cv1
        public ActionResult GetTableColumns(string tableName)
        {
            var columnsForTable = new List <DropDownItem>();

            if (!ModelState.IsValid)
            {
                return(Json(columnsForTable, JsonRequestBehavior.AllowGet));
            }
            var tableSchemaModels = _schemaRepository.GetSchemaTableColumns(tableName);
            IEnumerable <DropDownItem> tempColumnList = tableSchemaModels.MetaData.Select(col => new DropDownItem
            {
                DropDownDisplay = col.Name,
                DropDownValue   = $"{tableName}.{col.Name}"
            }).OrderBy(x => x.DropDownDisplay).ToList();

            columnsForTable = GetSelectListItems(tempColumnList).ToList();
            return(Json(columnsForTable, JsonRequestBehavior.AllowGet));
        }
コード例 #3
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)
            });
        }
コード例 #4
0
ファイル: ConvertModelToJson.cs プロジェクト: lvwf1/o2cv1
        public string ConvertSimpleTableQuery(string tableName)
        {
            try
            {
                TableSchemaModel columnData = schemaRepository.GetSchemaTableColumns(tableName);
                var simpleQuery             = new ComposedQuerySimple
                {
                    root = new Root
                    {
                        enabled  = true,
                        linkType = "All"
                    },
                    modelId   = Guid.NewGuid().ToString(),
                    modelName = null
                };

                var columns = new List <Column>();

                foreach (var item in columnData.MetaData)
                {
                    var column = new Column
                    {
                        caption   = $"{tableName} {item.Name}",
                        sortIndex = -1,
                        sorting   = "None",
                        expr      = new Expr
                        {
                            typeName = "ENTATTR",
                            id       = $"{tableName}.{item.Name.ToString()}",
                        },
                        ParmObjects = new List <object>()
                    };
                    columns.Add(column);
                }
                simpleQuery.columns = columns;

                return(JsonConvert.SerializeObject(simpleQuery));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        public void SchemaRepositoryReturnTableColumnInformationCities()
        {
            var result = schemaRepository.GetSchemaTableColumns("Cities");

            Assert.AreEqual(2, result.MetaData.Count);
        }