/// <summary> /// 设置表名 /// </summary> private void SetTableName() { var tableArr = EntityType.GetCustomAttribute <TableAttribute>(false); if (tableArr != null) { TableName = tableArr.Name; } else { TableName = EntityType.Name; //去掉Entity后缀 if (TableName.EndsWith("Entity")) { TableName = TableName.Substring(0, TableName.Length - 6); } } //判断有没有设置前缀 if (SqlAdapter.Options.Prefix.NotNull()) { var prefixIgnoreArr = EntityType.GetCustomAttribute <PrefixIgnoreAttribute>(false); if (prefixIgnoreArr == null) { TableName = SqlAdapter.Options.Prefix + TableName; } } if (SqlAdapter.ToLower) { TableName = TableName.ToLower(); } }
/// <summary> /// Initializing <see cref="SqlDataProvider{TEntity}"/> /// </summary> /// <param name="dbConnectionFactory">Factory providing database connection</param> /// <exception cref="ArgumentNullException">Parameter dbConnectionFactory is null</exception> /// <exception cref="ArgumentNullException">Parameter dbAdapter is null</exception> public SqlDataProvider(IDbConnectionFactory dbConnectionFactory, IDbAdapter dbAdapter) { DbConnectionFactory = dbConnectionFactory ?? throw new ArgumentNullException(nameof(DbConnectionFactory)); DbAdapter = dbAdapter ?? throw new ArgumentNullException(nameof(dbAdapter)); TableName = typeof(TEntity).Name; if (!TableName.EndsWith("s")) { TableName += "s"; } EntityFields = GetEntityFields(); }
public bool Init <TKey>(DbDebugItem <TKey> debug) { FileOutput = debug.FilePath; OriginalTableName = TableName = Path.GetFileNameWithoutExtension(FileOutput); if (TableName == null || OriginalTableName == null) { return(false); } if (TableName.EndsWith("_re")) { IsRenewal = true; } debug.FilePath = TempPath; debug.FileType = FileType.Txt; Builder = new StringBuilder(); if (debug.DestinationServer == ServerType.Hercules) { NewLine = NewLineFormat.Unix; IsHercules = true; } else { NewLine = NewLineFormat.Windows; IsRAthena = true; } if (debug.DestinationServer == ServerType.Hercules) { // mob_db2_re > mob_db2 // item_db2_re > item_db2 // etc TableName = OriginalTableName.Replace("2_re", "2"); FileOutput = FileOutput.Replace("2_re.sql", "2.sql"); } PrintEmptyLines = true; return(true); }