我之前正在使用MVC4/EF5创建一个项目,并且已经开始了一个新项目(为了最简单的方法),并开始重新创建到目前为止我在MVC5/EF6中所拥有的东西,其中包括利用ASP.NET身份。
在我的IdentityModels.cs中,我添加了几个属性,如NAME、POSITION、LASTVISITDATE等。在IdentityModel.cs属性上,我还添加了Grid.MVC Data Annotations,它允许我快速轻松地将特定模型属性的表格和分页布局显示到视图中。
现在,我所有的旧代码都可以有效地运行了,但PasswordHash、SecurityStamp、TwoFactorEndabled等Asp.NET Identity属性也显示在我的Grid.MVC中。
有没有办法为这些Identity属性提供NotMappedColumn的Grid.MVC注释,或者我需要将Grid.MVC的使用划归其他用途?
我真的很想使用我的Grid.MVC方法在我的视图中显示数据,如果可能的话,因为在模型上做一些小注释,我就能够在视图中使用一些简短的代码来呈现我希望的所有数据:
<div class="overflowPrevention">
@*Images in Columns: https://gridmvc.codeplex.com/discussions/440977*@
@Html.Grid(Model).Columns(columns =>
{
columns.Add().Encoded(false).Sanitized(false).RenderValueAs(o => Html.ActionLink("Edit", "Edit", "UserManage", new { id = o.Id }, null));
columns.Add().Encoded(false).Sanitized(false).RenderValueAs(u => Html.ActionLink("Delete", "Delete", "UserManage", new { id = u.Id }, null));
columns.Insert(2, u => u.ProfilePictureUrl).Titled("User Img").Encoded(false).Sanitized(false).RenderValueAs(u => @<img class="" src="@u.ProfilePictureUrl" alt="Current Profile Image" width="75px" height="75px" />);
}).AutoGenerateColumns()
</div>发布于 2014-05-30 06:39:00
一个解决方案是为您的视图创建一个视图模型,它只包含必要的属性,而不是将您的视图强类型化为您的域用户模型。
https://stackoverflow.com/questions/23937061
复制相似问题