private void Remove(ColumnNameToPropertyName columnNameToPropertyName, bool favorTable) { // favoring single return queries for readability; despite performance hit ColumnNameToPropertyName toRemove = favorTable ? ColumnNamesToPropertyNames.FirstOrDefault(c => c.TableName.Equals(columnNameToPropertyName.TableName) && c.ColumnName.Equals(columnNameToPropertyName.ColumnName)) : ColumnNamesToPropertyNames.FirstOrDefault(c => c.TableName.Equals(columnNameToPropertyName.TableName) && c.PropertyName.Equals(columnNameToPropertyName.PropertyName)); if (toRemove != null) { ColumnNamesToPropertyNames.Remove(toRemove); } }
public string GetPropertyName(string tableName, string columName) { ColumnNameToPropertyName lookup = ColumnNamesToPropertyNames.FirstOrDefault(c => c.TableName.Equals(tableName) && c.ColumnName.Equals(columName)); if (lookup != null) { return(lookup.PropertyName); } return(columName); }
public string GetColumnName(string className, string propertyName) { string tableName = GetTableName(className); ColumnNameToPropertyName lookup = ColumnNamesToPropertyNames.FirstOrDefault(c => c.TableName.Equals(tableName) && c.PropertyName.Equals(propertyName)); if (lookup != null) { return(lookup.ColumnName); } return(propertyName); }
public void Set(ColumnNameToPropertyName columnNameToPropertyName) { Remove(columnNameToPropertyName, true); Remove(columnNameToPropertyName, false); ColumnNamesToPropertyNames.Add(columnNameToPropertyName); }