Closed dalenewman closed 3 years ago
Okay this works. I'm using a questionable approach to grab the database provider and connection string...
using(var cn = _dbConnectionAccessor.CreateConnection()) {
connection.ConnectionString = cn.ConnectionString;
connection.Provider = _store.Dialect.Name.ToLower();
}
Seems like I should be able to get this information without creating a connection.
Example...
<cfg name="Users">
<connections>
<add name="orchard" />
</connections>
<entities>
<add name='UserIndex'>
<fields>
<add name="Id" type="int" primary-key="true"/>
<add name="DocumentId" type="int" label="Doc Id" />
<add name="NormalizedUserName" label="Username" length="255"/>
<add name="NormalizedEmail" label="Email" length="255"/>
<add name="IsEnabled" label="Enabled" type="bool"/>
</fields>
</add>
</entities>
</cfg>```
Note: If you're using PostgreSql against this Orchard Core created table, you will have to add `enclose="true"` to the connection. This is because Orchard double quotes all the identifiers it creates when using PostgreSql.
It would be useful for arrangements to reference a built in connection (without knowing the provider or credentials).
e.g.
In the same way that common connections are referenced by name, the orchard core's site connection could be used for reports, forms, or tasks. Side benefits are better security and less configuration.
Links
Notes
Tagged: @vlad2kgithub