-
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
+更新dto方法 #218
Comments
根据 Dto 更新 fsql.Update<T>()
.SetDto(new { title = "xxx", clicks = 2 })
.Where(a => a.Id == 1)
.ExecuteAffrows();
//UPDATE `tb_topic` SET `Title` = ?p_0, `Clicks` = ?p_1 WHERE (Id = 1)
fsql.Update<T>()
.SetDto(new Dictionary<string, object> { ["title"] = "xxx", ["clicks"] = 2 })
.Where(a => a.Id == 1)
.ExecuteAffrows(); |
2881099
pushed a commit
that referenced
this issue
Feb 28, 2020
2881099
pushed a commit
that referenced
this issue
Feb 28, 2020
大佬,你好,Insert是否也能添加类似匿名,或者Dto方式的录入呢? |
不一样,更新才需要指定字段。插入可以考虑把 Dto 对象映射成 Entity 在插入 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
增加直接更新dto所有数据 + 实体审计数据的功能
为解决attach(entity) 会意外更新其它字段或者默认值无变化无法更新该字段的问题
entity = entityRep.getAsync(dto.id)
_mapper.Map(dto)
entityRep.UpdateAsync(entity) 这里更新需要查询再更新有变化的字段
场景:
_entity仓储.updateDto(dto) => update entityTable set dto.所有字段 + 内部获取 new entity(){ }.更新审计字段
The text was updated successfully, but these errors were encountered: