We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
基本需求是,读取数据表A里的数据,筛掉部分数据之后之后,将有效数据写入数据表A_fix,想通过 AsTable 来指定写入数据表的表名。 我写了以下方法来实现,但是发现执行的SQL代码中,并不是newtablename表名,而是原来的默认表名(TableAttribute指定的表名)。 PS:我的写入数据库是达梦的
// c# code /// <summary> /// 替换表格数据 /// </summary> /// <typeparam name="T">数据类型</typeparam> /// <param name="dataList">数据列表</param> /// <param name="db">数据库</param> /// <param name="tableNameSuffix">表名尾缀,基于原表名增加的尾缀</param> /// <exception cref="NotImplementedException"></exception> private void replaceTableData<T>(List<T> dataList, IFreeSql db, string tableNameSuffix) where T : class { // 获取类型 var type = typeof(T); // 获取 Table 特性 var tableAttribute = type.GetCustomAttribute<FreeSql.DataAnnotations.TableAttribute>(); // 新表名 var newtablename = tableAttribute.Name + tableNameSuffix; try { var delResult = db.Delete<T>().AsTable(newtablename).Where(q => true).ExecuteAffrows(); } catch (Exception er) { Log4NetExtension.GetLogger().Error($"[{type.FullName}]删除表数据时发生异常", er); } var insResult = db.Insert<T>(dataList).AsTable(newtablename).ExecuteAffrows(); }
The text was updated successfully, but these errors were encountered:
统一加前缀,建议看aop文档。
Sorry, something went wrong.
No branches or pull requests
问题描述及重现代码:
基本需求是,读取数据表A里的数据,筛掉部分数据之后之后,将有效数据写入数据表A_fix,想通过 AsTable 来指定写入数据表的表名。
我写了以下方法来实现,但是发现执行的SQL代码中,并不是newtablename表名,而是原来的默认表名(TableAttribute指定的表名)。
PS:我的写入数据库是达梦的
数据库版本
安装的Nuget包
.net framework/. net core? 及具体版本
The text was updated successfully, but these errors were encountered: