-
I have a very complex query that requires directly using SQL in my Orchard site which is stored in MariaDB. I have a MariaDB database view I want to use but don't see any "Create" methods on SchemaBuilder which seems like it would be the place to find such funtionality (since it has CreateTable, CreateForeignKey, CreateMapIndexTable, etc). I want to manage view creation/updating like all other database stuff, through migrations... but can't seem to find a way. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
So, I have a solution I'm posting in case it might be helpful for someone else... not sure if this is the right way or if it might be weird... First I tried working with the connection on the SchemaBuilder I'm using in other places in my migration class, assuming I could plug into whatever transaction was going on there: var command = SchemaBuilder.Connection.CreateCommand();
command.CommandText = "CREATE VIEW nodes AS select * from siteNodePartIndex;";
command.ExecuteNonQuery(); Unfortunately that gives and error I couldn't solve: using var connection = _dbConnectionAccessor.CreateConnection();
connection.Open();
var command = connection.CreateCommand();
command.CommandText = "create view theViewName as select * from theTable;";
command.ExecuteNonQuery();
connection.Close(); The above works for me so that is what I'm doing for now but please let me know if anyone has any better, more proper "Orchard" ways. Thanks! |
Beta Was this translation helpful? Give feedback.
So, I have a solution I'm posting in case it might be helpful for someone else... not sure if this is the right way or if it might be weird... First I tried working with the connection on the SchemaBuilder I'm using in other places in my migration class, assuming I could plug into whatever transaction was going on there:
Unfortunately that gives and error I couldn't solve:
The transaction associated with this command is not the connection's active transaction; see https://fl.vu/mysql-trans
So, then I noticed there is an IDbConne…