Subsonic 简单存储库字符串长度
我正在 SubSonic 3 中使用 SimpleRepository 提供程序(带有自动迁移),但遇到了一个恼人的问题:
控制数据库表中字符串长度的唯一方法是将 SubSonicStringLength 或 SubSonicLongString 属性添加到对象的属性中是需要坚持的。
除了我的存储库类之外,我真的不想在任何地方依赖 SubSonic,如果可以避免的话,当然也不希望在我的模型对象中依赖 SubSonic。
有没有办法解决这个问题,或者我是否坚持使用 SubSonicStringLength 和其他属性?
I'm playing around with the SimpleRepository provider (with automigrations) in SubSonic 3 and I have an annoying problem:
The only way I can control the string length in my database tables is by adding the SubSonicStringLength or SubSonicLongString attributes to the properties of the objects that need to be persisted.
I don't really want a dependency on SubSonic anywhere except in my repository class, and certainly not in my model objects if I can avoid it.
Are there anyways to get round this or am I stuck using SubSonicStringLength and the other attributes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,解决这个问题的唯一方法是使用一个 DTO 对象,将其映射到存储库内的 SimpleRepository 类或从存储库中的 SimpleRepository 类映射。您可以使用 AutoMapper 等映射工具在 DTO 与 SimpleRepo 对象之间进行转换。
这会将您的应用程序与存储库外部的 SubSonic 依赖项隔离开来,但显然会涉及大量工作。
Basically the only way around this would be to have a DTO object that you map to/from your SimpleRepository classes inside your repository. You could use a mapping tool like AutoMapper to convert to/from your DTOs to your SimpleRepo objects.
This would isolate your application from SubSonic dependencies outside of your repo but would obviously involve a non trivial amount of work.