public static string GetTableName(this ICURDProperties updateProperties, string tableIndex = null, int id = 0) { var tableAttribute = updateProperties.GetCustomerAttributes <MatchedTableAttribute>().FirstOrDefault(w => w.ID == id); var tableName = tableAttribute?.Name; if (string.IsNullOrEmpty(tableName)) { tableName = updateProperties.GetType().Name; } //tableName = tableName.Trim();//Support Use Sencond Type TableIndex For Table FullName var ITableSharding = updateProperties as ITableSharding; string tableNameFormat = string.Empty; if (ITableSharding != null) { tableNameFormat = string.Format(tableName, ITableSharding.__TableIndex__); if (tableIndex == null) { return(tableNameFormat); } } if (tableName.StartsWith("{") && tableName.EndsWith("}")) { tableName = AppSetting.GetConfig(tableName.TrimStart('{').TrimEnd('}')); } if (tableName.Contains("{") && tableName.Contains("}")) { tableNameFormat = string.Format(tableName, tableIndex); return(tableNameFormat); } return(tableName); }
public static string GetConnectionKey(this ICURDProperties updateProperties, int id = 0) { var tableAttribute = updateProperties.GetCustomerAttributes <MatchedTableAttribute>().FirstOrDefault(w => w.ID == id); var connectionKey = tableAttribute?.ConnectionKey; if (string.IsNullOrEmpty(connectionKey)) { return(connectionKey); } connectionKey = connectionKey.Trim(); if (connectionKey.StartsWith('{') && connectionKey.EndsWith('}')) { connectionKey = AppSetting.GetConfig(connectionKey.TrimStart('{').TrimEnd('}')); } return(connectionKey); }
public static MatchedTableAttribute GetMatchedTableAttribute(this ICURDProperties updateProperties, int id = 0) { var tableAttribute = updateProperties.GetCustomerAttributes <MatchedTableAttribute>().FirstOrDefault(w => w.ID == id); return(tableAttribute); }