public IDbModelStrategy <TModel> Table <TModel>(string tableName, string tableAlias) where TModel : class, new() { IDbModelStrategy <TModel> modelStrategy = new DbModelStrategy <TModel>(tableName, tableAlias); if (_modelStrategies.ContainsKey(typeof(TModel))) { if (_modelStrategies[typeof(TModel)] == null) { _modelStrategies[typeof(TModel)] = modelStrategy; return(modelStrategy); } if (TryConvertModelStrategy(_modelStrategies[typeof(TModel)], out modelStrategy)) { modelStrategy = (IDbModelStrategy <TModel>)_modelStrategies[typeof(TModel)]; modelStrategy.ChangeTableName(tableName, tableAlias); _modelStrategies[typeof(TModel)] = modelStrategy; return(modelStrategy); } _modelStrategies[typeof(TModel)] = modelStrategy; return(modelStrategy); } _modelStrategies.Add(typeof(TModel), modelStrategy); return(modelStrategy); }
public IDbModelStrategy <TModel> Table <TModel>() where TModel : class, new() { var tableName = typeof(TModel).Name; var attrTableNames = (TableAttribute[])typeof(TModel).GetCustomAttributes(typeof(TableAttribute), true); if (attrTableNames.Length > 0) { tableName = attrTableNames[0].TableName; } IDbModelStrategy <TModel> modelStrategy = new DbModelStrategy <TModel>(tableName); if (_modelStrategies.ContainsKey(typeof(TModel))) { if (_modelStrategies[typeof(TModel)] == null) { _modelStrategies[typeof(TModel)] = modelStrategy; return(modelStrategy); } if (TryConvertModelStrategy(_modelStrategies[typeof(TModel)], out modelStrategy)) { modelStrategy = (IDbModelStrategy <TModel>)_modelStrategies[typeof(TModel)]; modelStrategy.ChangeTableName(tableName); _modelStrategies[typeof(TModel)] = modelStrategy; return(modelStrategy); } _modelStrategies[typeof(TModel)] = modelStrategy; return(modelStrategy); } _modelStrategies.Add(typeof(TModel), modelStrategy); return(modelStrategy); }
public IDbModelStrategy Table(Type modelType, string tableName, string tableAlias) { var modelStrategy = new DbModelStrategy(modelType, tableName, tableAlias); if (_modelStrategies.ContainsKey(modelType)) { return(_modelStrategies[modelType] as IDbModelStrategy); } _modelStrategies.Add(modelType, modelStrategy); return(modelStrategy); }
public IDbModelStrategy Table(Type modelType) { var tableName = modelType.Name; var attrTableNames = (TableAttribute[])modelType.GetCustomAttributes(typeof(TableAttribute), true); if (attrTableNames.Length > 0) { tableName = attrTableNames[0].TableName; } var modelStrategy = new DbModelStrategy(modelType, tableName); if (_modelStrategies.ContainsKey(modelType)) { return(_modelStrategies[modelType] as IDbModelStrategy); } _modelStrategies.Add(modelType, modelStrategy); return(modelStrategy); }