0

I'm using the Database-first EF model, and use breezeJs for the client-side data management.

Let's say I have a table [User] in my database, with a field called 'AccessCode'. I want to expose the User object through breeze to the clientside, but do not want to expose the AccessCode property. As far as I know, I have the following options:

  1. Make the AccessCode property on the EF generated entity class Internal.
  2. Create a DTO and omnit the AccessCode property. DTO is exposed to the client side.

2nd option doesn't work well with breeze, since we should be able to add/modify the User object directly from clientside.

Is there anything wrong with the first option? My concern is that if we make the property internal, the change will be wiped the next time the model is updated. I know if we want to enforce validations, we can use partial classes with the entity class, but we can't do that here.

What would be the best way to achieve the data-hiding here?

4

1 回答 1

0

当您想要隐藏不同层的数据时,DTO 几乎总是正确的答案。

于 2015-08-20T13:17:20.327 回答