如何使字段不可更新 [英] how to make field not updateable

查看:58
本文介绍了如何使字段不可更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我根据数据库中的某个表生成了一个实体,我想在我的实体中指定不要在更新表达式中使用某些列/字段并且只读。这样做的正确方法是什么?


提前感谢

解决方案


还没有真正支持EF中的只读属性。您可以在属性上设置setter,EF仍将实现属性,您的消费代码将无法访问setter。


~Rowan


Hi,

I generated an entity based on some table in a database, I would like to specify in my entity not to use some columns/fields in update expression and be read only. what is the right way of doing that?

thanks in advance

解决方案

Hi,

There isn't true support for read-only properties in EF yet. You could make the setter on the properties protected though, EF will still materialize to the properties and your consuming code won't have access to the setter.

~Rowan


这篇关于如何使字段不可更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆