asp.net-mvc – MVC包含路径无效错误
发布时间:2020-12-16 09:19:58 所属栏目:asp.Net 来源:网络整理
导读:调节器 public ActionResult Index(int? id){ var userEmail = User.Identity.Name; var model = db.Staffs.Where(i = i.Email == userEmail).Include("Histories").Include("CurrentApplications").FirstOrDefault(); return View(model);} 行var var model
调节器
public ActionResult Index(int? id) { var userEmail = User.Identity.Name; var model = db.Staffs.Where(i => i.Email == userEmail).Include("Histories").Include("CurrentApplications").FirstOrDefault(); return View(model); } 行var var model = db.Staffs.Where(i => i.Email == userEmail).Include(“Histories”).包含(“CurrentApplications”).FirstOrDefault();但我不知道为什么我得到它. 错误
员工班 public partial class Staff { public int StaffID { get; set; } public string Name { get; set; } public string Email { get; set; } public Nullable<decimal> AllocatedLeave { get; set; } public Nullable<int> BalanceLeave { get; set; } public virtual IEnumerable<History> Histories { get; set; } public virtual IEnumerable<CurrentApplication> CurrentApplications { get; set; } } 解决方法
我相信在定义Navigation属性时可能需要使用ICollection而不是IEnumerable.这可能是个问题.
我还建议(假设您的Entity Framework版本足够高,以支持它)使用强类型包含,这样如果您在Staff.cs中更改属性,您将收到编译时错误. 即:.Include(s => s.Histories) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.NET将原始HTML解析为控件
- asp.net-mvc – 如何使用存储库模式处理表关系?
- asp.net-mvc – ASP.NET MVC Beta支持列表中的Model Binder
- 为什么我的asp.net应用程序抛出ThreadAbortException?
- asp.net-mvc – 如何在@ Html.TextBox mvc4中添加新的css类
- asp.net+js实现批量编码与解码的方法
- asp.net – 每个Web服务器的Azure Service Bus主题订阅
- 在asp.net MS图表控件上显示工具提示
- .net – Nuget包,没有nuget包管理器?
- asp.net-mvc – 如何在MVC Unobtrusive Validation中验证Da
推荐文章
站长推荐
- asp.net-mvc – 使用razor引擎在mvc4中重写url
- 最好的ASP.net WYSIWYG
- asp.net – 在控制台.NET核心应用程序中创建用户
- asp.net-mvc – 在Umbraco 6.1.1 MVC 4中,如何使
- asp.net-mvc-3 – @ Html.ActionLink和@ Html.Di
- asp.net-mvc – MVC DDD:可以将存储库与控制器中
- asp.net-mvc-3 – ASP.Net Mvc 3 Url.Action方法
- asp.net-mvc-3 – 使用connectionStringName进行
- asp.net-mvc – 对Json解决方法的EntityFramewor
- 什么是IIS和Asp.Net中的应用程序池?
热点阅读