Question

I accept that this is frowned upon but if someone can humor me that would be great.

Id like to call data from an orchard module using a sql string. To do this I assume i need to get the table prefix if specified when creating the tenant and also the feature prefix for the module.

So for example.

string tenentPrefix = //Wherever I get it from?
string modulePrefix = //Wherever I get it from?

string sql = string.Format("select * from {0}{1}MyTableName",tenentPrefix, modulePrefix); 
//MyTableName obviously being the name of the model

Your help greatly appreciated.

Was it helpful?

Solution

If you inject ShellSettings, then you can access DataTablePrefix on it. That answers the first part. For the second part, hopefully you know the module name, so it should be easy to translate it into the table name by replacing the dots with underscores. ShellBuilder.CompositionStrategy does it this way:

var extensionDescriptor = feature.Descriptor.Extension;
var extensionName = extensionDescriptor.Id.Replace('.', '_');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top