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); }
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)); }
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) }); }
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; } }
public void SchemaRepositoryReturnTableColumnInformationCities() { var result = schemaRepository.GetSchemaTableColumns("Cities"); Assert.AreEqual(2, result.MetaData.Count); }