public override string ColumnName(IGRCell CellProp) { if (CellProp.Property.Name == "Result") { return(TableHeaderSource.Result); } return(ColumnNameResolver.FTSColumns(CellProp.Property.Name)); }
public override string ColumnName(IGRCell BkProp) { switch (BkProp.Property.Name) { case "Zone": return(ColumnNameResolver.IBookProcess(BkProp.Property.Name)); } return(BookItem.PropertyName(BkProp.Property)); }
/// <summary> /// Gets the name of the column in the database for the specified type, /// using the configured <see cref="IColumnNameResolver"/>. /// </summary> /// <param name="propertyInfo">The <see cref="PropertyInfo"/> to get the column name for.</param> /// <param name="sqlBuilder">The SQL builder instance.</param> /// <returns>The column name in the database for <paramref name="propertyInfo"/>.</returns> public static string Column(PropertyInfo propertyInfo, ISqlBuilder sqlBuilder) { var key = $"{sqlBuilder.GetType()}.{propertyInfo.DeclaringType}.{propertyInfo.Name}"; if (!_columnNameCache.TryGetValue(key, out var columnName)) { columnName = sqlBuilder.QuoteIdentifier(ColumnNameResolver.ResolveColumnName(propertyInfo)); _columnNameCache.TryAdd(key, columnName); } LogReceived?.Invoke($"Resolved column name '{columnName}' for '{propertyInfo}'"); return(columnName); }
protected override object VisitMemberAccess(MemberExpression expression) { if (expression.Member is PropertyInfo jsonValue && expression.Expression is MemberExpression jsonContainerExpr && jsonContainerExpr.Member is PropertyInfo jsonContainer && jsonContainer.IsDefined(typeof(JsonDataAttribute))) { return(SqlBuilder.JsonValue( VisitMemberAccess(jsonContainerExpr).ToString(), ColumnNameResolver.ResolveColumnName(jsonValue))); } return(base.VisitMemberAccess(expression)); }
protected override VisitResult VisitMemberAccess(MemberExpression expression) { if (expression.Member is PropertyInfo jsonValue && expression.Expression is MemberExpression jsonContainerExpr && jsonContainerExpr.Member is PropertyInfo jsonContainer && jsonContainer.IsDefined(_options.JsonDataAttributeType)) { var memberAccessResult = VisitMemberAccess(jsonContainerExpr); return(new VisitResult(SqlBuilder.JsonValue(memberAccessResult.Result.ToString(), ColumnNameResolver.ResolveColumnName(jsonValue)))); } return(base.VisitMemberAccess(expression)); }
public override void StructTable() { if (MatchTable != null) { return; } List <IGRCell> PsProps = new List <IGRCell>(); Type StringType = typeof(string); PsProps.AddRange( typeof(FTSResult).GetProperties() .Where(x => x.PropertyType == StringType) .Remap(p => new GRCell <FTSResult>(p)) ); MatchTable = new GRTable <FTSResult>(PsProps); TableHeaderSource = new FTSResult(-1, ColumnNameResolver.FTSColumns("Result")); MatchTable.Source = TableHeaderSource; MatchTable.Cell = (i, x) => MatchTable.ColEnabled(i) ? ColumnName(MatchTable.CellProps[i]) : ""; }
public override string ColumnName(IGRCell CellProp) => ColumnNameResolver.TSTColumns(CellProp.Property.Name);
public CachingNameResolver(INameFormatter nameFormatter) { _columnNameResolver = new ColumnNameResolver(nameFormatter); _tableNameResolver = new TableNameResolver(nameFormatter); }