实体框架&带有部分类的 CRUD
在 ASP.Net v4 页面中,我为 EF4 设置了一个 EntityDataSource,并将其绑定到一个 DetailsView,允许查看、编辑和新建实体。 一切正常,直到我将属性添加到所绑定实体的分部类中:
namespace MyProject.EntityFramework
{
public partial class Member
{
public bool CurrentMember
{
get
{
//do some stuff
return true;
}
}
因为计算了“CurrentMember”,所以没有设置该属性,并且在尝试插入或更新时遇到各种错误。 在属性中添加 [ReadOnly(true)] 属性并没有帮助,将visible 设置为 false 也没有帮助。
这看起来很基本。我做错了什么?
ASP.Net v4 page, I have setup an EntityDataSource for EF4, and am binding this to a DetailsView allowing view, edit and new for an Entity.
All works fine until I add a property to the partial class of the entity being bound:
namespace MyProject.EntityFramework
{
public partial class Member
{
public bool CurrentMember
{
get
{
//do some stuff
return true;
}
}
Because 'CurrentMember' is calculated there is no set for the property and I get a variety of errors when trying to either insert or update.
Adding an attribute of [ReadOnly(true)] to the property does not help, nor does setting visible to false.
This seems basic. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论