添加/删除记录(如果存在或不存在)
我正在制作一个应用程序,用户上传文件,然后选择与该文件关联的所有类别。
第一个视图用户可以选择上传文件,然后会出现一组复选框,用于添加所需的类别。
编辑文件时会出现问题,您可以选择选中/取消选中复选框,取消选中意味着删除记录(如果存在)并选中意味着如果不是则添加
我无法弄清楚如何使此场景的 linq 查询添加/删除(如果是或不是)
I am making an application the user uploads a file and then choose all the categories associated with the file.
the first view the user has the option to upload a file then a group of checkboxes appears for adding the required categories
the problem comes when editing a file you can choose to check/uncheck the checkboxes uncheck means delete the record if it was there and check means add if it wasn't
i can't figure out how to make the linq query for this scenario to add/delete if it was or wasn't
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户单击“更新”时,您可以先删除所选文件与其相关类别之间的所有关联,然后仅插入所选文件,现在您可以确定它们不存在。
When the user click "update" , you could first delete all the associations between the selected file and his related categories, then insert only the selected ones, and now you're sure they don't exists.