-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
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
Column.RereadSql使用其他字段判断动态获取时, 无法在多表关联中指定表别名 #1655
Comments
应该不会有其他表的访问情况? 解决方向,是否只考虑本表即可 |
[Column(RereadSql = "IIF([IsEnabled] = 1, {0}, {0} + '-已停用')")] public bool IsEnabled { get; set; } 暂定,使用方括号代表替换为目标 alias.column 方括号内容,可以是属性名,或者字段名。 |
|
|
[Column(RereadSql = "IIF({IsEnabled} = 1, {0}, {0} + '-已停用')")] public bool IsEnabled { get; set; } 使用花括号吧! |
可以考虑多个字段的情况 |
SELECT a. 待发布 |
问题描述及重现代码:
预期: Test作为字典表,通过IsEnabled字段实现非启用状态下查询时ItemName 字段附加"-已停用"后缀
问题: 单表查询可以实现, 多表关联时, 获取不到Test的表别名, 此时多次关联Test表时, 生成sql语句执行时提示"IsEnabled"列不明确
期望: [Column(RereadSql = "IIF(IsEnabled = 1, {0}, {0} + '-已停用')")] 中通过占位符指定当前的表别名
例如: [Column(RereadSql = "IIF({tableAlias}.IsEnabled = 1, {tableAlias}.{0}, {tableAlias}.{0} + '-已停用')")]
生成的sql
数据库版本
SQL Server 2019 EE
安装的Nuget包
.net framework/. net core? 及具体版本
net6.0
The text was updated successfully, but these errors were encountered: