域对象与其关系表的良好命名约定是什么?
我已经看到这个问题两次了,想看看解决这个命名约定的最佳实践是什么。 假设我有一个 ORM(本例中为 Linq to SQL)并且映射了一个名为 User 的表。 然后我创建了我的 POCO,也称为 User。 虽然映射表存在于类似的东西中
MyApp.Data.User
,并且 POCO 驻留在类似的东西中,
MyApp.Objects.User
但我意识到可以在整个代码中对其中任何一个进行完整的名称空间标识,但是您是否有一个合理的命名约定,以便您可以轻松分辨哪个是表映射,哪个是表映射是POCO吗? 谢谢!
I have seen this issue twice now and want to see what a best practice is for resolving this naming convention. Suppose I have an ORM (Linq to SQL in this case) and I map a table called User. Then I create my POCO called User also. Although the mapped table exists in something like
MyApp.Data.User
and the POCO resides in something like
MyApp.Objects.User
I realize one can do a full namespace identification for either throughout the code, but do you have a sensible naming convention so you can tell easily which is the table mapping and which is the POCO? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我用来调用 Linq2SQL 对象 DbUser 等。
这使得扫描代码并查看哪个是哪个变得非常容易,并且由于 L2S 数据对象只能在 DataTier 中访问,因此奇怪的命名不再是问题。
I use to call the Linq2SQL objects DbUser and so on.
This makes it very easy to scan through the code and see which is which, and since the L2S data objects are only accessible in the DataTier, the wierd naming is less of a problem.
我将该映射命名为 UserMapping。
因为事情就是这样。
I would name the mapping UserMapping.
Because that's what it is.
或者将其命名为 UserModel 怎么样?然后您就可以拥有 VM 版本的 UserModelView。
Or what about naming it UserModel - then you can have UserModelView for the VM version.