如何覆盖记录表命名以访问 Orchard CMS 中的现有数据
我需要访问预先存在的表中的数据。我已经开始通过创建一个模块来显示数据等来工作。但是,Orchard 使用“Table_Prefix”和“模块名称”为表命令添加前缀。
有什么方法可以指定绑定模型的表,以便我可以使用现有的 IRepository
我试图避免修改核心代码,或实现我自己的 IRepository (我有一种感觉是什么我必须这样做。)
提前致谢。
I need to access data from pre-existing tables. I've started working my way through creating a module to display the data etc. However, Orchard is prefixing the table commands with the 'Table_Prefix' and 'Module Name'.
Is there any way I can specify what table to bind the model, so that I can use the existing IRepository
I'm trying to steer clear of modifying the core code, or implement my own IRepository ( which I've got a feeling is what I'm going to have to do.)
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过以下三种方式更改核心代码来创建自定义表命名约定(以便它适合您当前的命名):
BuildRecord
方法中创建的CompositionStrategy
类(Orchard.Framework/Environment/ShellBuilders/CompositionStrategy),因此您可以简单地修改此处的代码。
Apply
方法Orchard.Data.Conventions.RecordTableNameConvention
类。这是记录表名称映射(在第 1 点中内置)被推送到 NHibernate 的地方。FluentNHibernate.Conventions.IClassConvention
实现(类似于上面提到的RecordTableNameConvention
并替换AutoMap
使用的默认实现) code> 在Orchard.Data.Providers.AbstractDataServicesProvider
的CreatePersistenceModel(...)
方法中,您也可以使用它来创建 。您自己的 IDataServicesProvider 实现,但如果您只需要更改表命名约定,那么这肯定是多余的。
You can create custom table naming convention (so that it would fit your current naming) by altering the core code, in three ways:
BuildRecord
method ofCompositionStrategy
class(Orchard.Framework/Environment/ShellBuilders/CompositionStrategy), so you can simply modify the code here.
Apply
method ofOrchard.Data.Conventions.RecordTableNameConvention
class. This is where the record table name mappings (built in point 1.) get pushed to NHibernate.FluentNHibernate.Conventions.IClassConvention
(similar toRecordTableNameConvention
mentioned above and replace the default one used byAutoMap
inOrchard.Data.Providers.AbstractDataServicesProvider
'sCreatePersistenceModel(...)
method with it.You could also create your own
IDataServicesProvider
implementation, but that would surely be an overkill if you only need to change the table naming convention.我正在修改 CompositionStrategy 并发现您必须修改以下
1. SetupService.cs (Modules\Orchard.Setup\Services):
Setup 方法中硬编码的表是
“Orchard_Framework_DataMigrationRecord”和
“Settings_ShellDescriptorRecord”
2。 InfosetController.cs (Modules\Upgrade\Controllers):
此类中硬编码了多个需要更新的表。
3. DataMigrationManager.cs (Data\Migration):
将 SchemaBuilder 参数替换为构造函数。
I was modifying CompositionStrategy and discovered that you have to modify the following
1. SetupService.cs (Modules\Orchard.Setup\Services):
Tables hardcoded in the Setup method are
"Orchard_Framework_DataMigrationRecord" and
"Settings_ShellDescriptorRecord"
2. InfosetController.cs (Modules\Upgrade\Controllers):
Multiple tables were hardcoded in this class which need to be updated.
3. DataMigrationManager.cs (Data\Migration):
Replace the SchemaBuilder parameters to the contructor.