【发布时间】:2020-07-11 09:53:58
【问题描述】:
我有 3 个外键 ID,它们来自同一个表,所以现在在下面的类中用表名引用它们 - 我怎么知道哪个对象引用了哪个 ID - 例如 Ids
公共部分类 InspectionResult { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] 公共检查结果() { this.EventLogs = new HashSet(); this.InspectionItems = new HashSet(); this.InspectionResultStatCounts = new HashSet(); this.NOVs = new HashSet(); this.UploadedDocuments = new HashSet(); this.AspNetUsers = new HashSet(); } 公共 int InspectionResultId { 获取;放; } 公共字符串 EnteredById { 获取;放; } 公共字符串 CreatedByUserId { 获取;放; } 公共字符串 UpdatedByUserId { 获取;放; } 公共虚拟 AspNetUser AspNetUser { 获取;放; } 公共虚拟 AspNetUser AspNetUser1 { 获取;放; } 公共虚拟 AspNetUser AspNetUser2 { 获取;放; } 公共虚拟 ICollection AspNetUsers { 获取;放; } }EnteredById、CreatedByUserId、UpdatedByUserId 来自同一个表 AspNetUser,但我怎么知道哪个 Id 属于 AspNetUser、AspNetUser1、、AspNetUser2 以及如何处理 AspNetUsers 对象?我正在使用 EF 数据库优先方法,请提供任何帮助 - 谢谢。
【问题讨论】:
标签: c# entity-framework