public IEnumerable <SchemaAttributeResponse> Evaluate(SchemaResponse schema) { if (schema == null) { throw new ArgumentNullException(nameof(schema)); } return(Evaluate(schema.Attributes)); }
public IEnumerable <SchemaAttributeResponse> Evaluate(SchemaResponse schema) { if (schema == null) { return(null); } return(Expression.Evaluate(schema)); }
public void GetFullName_With_NestedDictionary_IsSafe() { var data = new SchemaResponse() { NestDictionary = new Dictionary <string, IDictionary <string, Episode> >() }; var type = data.NestDictionary.GetType(); var sut = TypeHelper.GetFullName(type); var prohibitedCharacters = new List <char> { '~', ' ', ',' }; Assert.IsNotNull(sut); Assert.IsTrue(!sut.Any(t => prohibitedCharacters.Contains(t))); }
public async Task <SchemaResponse> GetSchemaAsync(string sqlConnStr, string schemaName = "dbo", string tblOrViewName = null) { var getSchemaSQL = @" SELECT TABLE_SCHEMA AS SchemaName, TABLE_NAME AS TableName, COLUMN_NAME AS ColumnName, DATA_TYPE AS DataType, CHARACTER_MAXIMUM_LENGTH AS CharMax, NUMERIC_PRECISION AS NumericPrecision, DATETIME_PRECISION AS DatePrecision, IS_NULLABLE AS IsNullable FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA <> 'sys' " + (string.IsNullOrWhiteSpace(tblOrViewName) ? " " : " AND TABLE_SCHEMA = @SchemaName AND TABLE_NAME = @TablOrViewName ") + "ORDER BY TABLE_SCHEMA DESC, TABLE_NAME ASC "; using (var conn = new SqlConnection(sqlConnStr)) { var results = await conn.QueryAsync <SchemaDetail>(getSchemaSQL, new { SchemaName = schemaName, TablOrViewName = tblOrViewName }, commandType : System.Data.CommandType.Text); var resp = new SchemaResponse() { Fields = results.Select(r => new SchemaField() { FieldName = r.ColumnName, FieldLabel = r.ColumnName, Description = r.ColumnName, IsDefault = false, DataType = _sqlDataTypeMap[r.DataType].Item1, Semantics = _sqlDataTypeMap[r.DataType].Item2, DefaultAggregationType = AggregationTypes.NONE, }).ToList() }; return(resp); } return(default(SchemaResponse)); }