Silverlight 4 中数据表单中的自定义业务逻辑
我正在使用领域服务和实体框架。 具有包含 4 个字段(ID、名称、年龄、MyLogic)的帐户实体
EF在我的示例 XAML 文件中
:我有 3 个字段,例如 ID、NAME、AGE。
在插入和更新数据时,我在 XAML 文件上有 3 个值,我需要将自定义逻辑插入到第四个字段中。像
MyLogic= Name-Age-ID(从数据库自动生成的新 ID)= 例如 Adam-58-NewPKValue
解决它的最佳实践是什么。 谢谢,
R
I am using Domain Services and Entity Framework. EF has account entity with 4 fields, ID,Name,Age, MyLogic
in My sample XAML file:
i have 3 fields for example ID, NAME,AGE.
While inserting and updating data, i have 3 values on XAML file and i need to insert custom logic into 4rth field. like
MyLogic= Name-Age-ID( new auto generated id from database)= eg Adam-58-NewPKValue
What is best practice to solve it.
Thanks,
R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有多种方法可以实现“伪”属性(即不存储在数据库中的值,而是根据其他值计算得出的值)。如果您使用 MVVM 模式,则可以将数据表单上的字段绑定到 ViewModel 中的通知属性。
为了使数据形式同步,其他三个属性的变异器必须调用“伪”属性的设置器。例如,当用户更改 Name 时,NameAgeId 属性将同时更新。
There are several ways to implement a 'pseudo' property (i.e., a value that is not stored in the database, but computed from other values instead). If you are using the MVVM pattern, you can bind the field on the data form to a notifying property in your ViewModel.
In order for the dataform to be in synch, the mutators for your other three properties would have to invoke the setter of your 'pseudo' property. So that, for example, when the user changed the Name, the NameAgeId property would be simultaneously updated.