在 Subsonic SimpleRepository 中使用我自己的属性
我最近一直在寻找 ORM,SubSonic 及其 SimpleRepository 似乎是我正在寻找的解决方案。
有没有办法使用我自己的属性或来自 System.ComponentModel 的属性来驱动某些 SQL 的生成?我想让我的模型/域对象远离第三方的东西。
I have been looking for an ORM of late and SubSonic with its SimpleRepository appears to be the solution I'm looking for.
Is there a way to use my own attributes or ones from System.ComponentModel
to drive some of the generation of the SQL? I want to keep my model/domain objects clean of third-party stuff.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不建议这样做,但这是可以做到的。
创建您自己的与 SubSonics 属性匹配的属性(例如
OrmIgnore
而不是SubSonicIgnore
,仍然需要实现SubSonic.SqlGeneration.Schema.IClassMappingAttribute
或 <代码>SubSonic.SqlGeneration.Schema.IPropertyMappingAttribute 或SubSonic.SqlGeneration.Schema.IRelationMappingAttribute
查看 SubSonic.Core\Extensions\Object.cs 中的代码,了解发生了什么情况,
您的 Apply 实现应该修改架构来执行您想要的操作。
就像这个(来自 SubSonicDefaultSettingAttribute):
您应该检查 SubSonic 源并将每个自定义属性标记为过时
有一些对属性(不使用接口)的直接引用需要修复。
你将不得不寻找字符串
引用
I wouldn't recommend that but this can be done.
Create your own attributes that match SubSonics attributes (like
OrmIgnore
instead ofSubSonicIgnore
, the still have to ImplementSubSonic.SqlGeneration.Schema.IClassMappingAttribute
orSubSonic.SqlGeneration.Schema.IPropertyMappingAttribute
orSubSonic.SqlGeneration.Schema.IRelationMappingAttribute
Look at this code from SubSonic.Core\Extensions\Object.cs to get an idea what's happening
your Apply implementation should modify the schema to do what you want.
Like this one (from SubSonicDefaultSettingAttribute):
You should check out the SubSonic source and mark every custom attribute as obsolete
There are some direct references to the attributes (that don't use the interface) that you will need to fix.
And you will have to look for string references
with