强制亚音速忽略特定的列名模式
我们使用 SubSonic 作为某种 ORM(实际上更多的是查询助手)。出于某种原因,我们有一点动态模式,因此某些表已经生成了列名等。嗯,到目前为止一切都很好。现在,我们的生产生成的列与我们的开发生成的列不匹配。我想到的第一个解决方法是在部署到生产服务器之前重新生成亚音速文件,但这似乎有点混乱。还有比这更好的办法吗?
请注意,这些生成的列实际上从未从 ORM 中使用过,但我们有时确实会使用下拉整行。
var data=MyData.DynamicTable.SingleOrDefault(x => x.id==1);
尽管在尝试加载 GenerateColumn10
或其他内容时使用开发生成的亚音速文件,这会在生产中引发错误,存在于开发中但不存在于生产中。
We use SubSonic as an ORM of sorts(really more of a query-helper). For one reason or another, we have a bit of a dynamic schema and as such certain tables have generated column names and such. Well, this has been all fine and dandy until now. Now, our production generated columns don't match up with our development generated columns. The first work around that came to mind is just regenerate the subsonic files before deploying to the production servers, but that seems a bit messy. Is there any better way than this?
Note, that these generated columns are never actually used from the ORM but we do sometimes pull down entire rows using
var data=MyData.DynamicTable.SingleOrDefault(x => x.id==1);
That would throw an error in production though using the development generated subsonic files when trying to load GeneratedColumn10
or whatever, which exists in development but not in production.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,我最终修改了 SQLServer 提供程序,以便它根据正则表达式检查每个列名称,以确定是否应包含该列。请务必注意,您必须对两列以及查找外键的位置执行此操作
I have actually ended up modifying the SQLServer provider so that it checks each column name against a regex to decide if the column should be included or not. It is important to note that you must do this for both columns and for where it looks up the Foreign Keys
您可以针对生产数据库创建 DAL 并将其与开发服务器一起使用。除非开发环境中的附加列不可为空并且没有指定默认值,否则您的更新和插入查询也将起作用。
You could create your DAL against the production DB and use it with your developement server. Unless your additional columns in the dev environment are not nullable and have no default value specified your update and insert queries will work, too.