Reputation: 107
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.
Upvotes: 3
Views: 927
Reputation: 1
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.
Upvotes: 0
Reputation: 13366
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 of
CompositionStrategy
class
(Orchard.Framework/Environment/ShellBuilders/CompositionStrategy), so you can simply modify the code here.Apply
method of Orchard.Data.Conventions.RecordTableNameConvention
class. This is where the record table name mappings (built in point 1.) get pushed to NHibernate.FluentNHibernate.Conventions.IClassConvention
(similar to RecordTableNameConvention
mentioned above and replace the default one used by AutoMap
in Orchard.Data.Providers.AbstractDataServicesProvider
's CreatePersistenceModel(...)
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.
Upvotes: 1