You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jzabroski and everyone else
Not sure if this issue has been discussed, but I felt there is need to have this interface as there are times where part of the MigrationUp() we need to query the database within the current context and set/update the migrating script according.
This interface would have a similar method signatures to IExecuteExpressionRoot the only difference is that those methods would return an IEnumerable<T>
The abstract class MigrationBase will have a new property of this interface and let's say we call it Query
So with the above settings we can achieve something along these lines below
[Migration(1,"Update user stored Proc ABC")]publicclassUpdateUserStoredProcABC:Migration{publicoverridevoidUp(){// new Query api here which returns an IEnumerable<T>varusers= Query.Sql<string>("SELECT u.name FROM sysusers g INNER JOIN sysusers u ON g.gid = u.gid");foreach(var user in users){
Execute.Sql($"SetUser '{user}'");
Execute.Script("whatever..");}//etc...}}
The alternative (not ideal) would be exposing IDbConnection as a property within the abstract class MigrationBase and let's say we call it DbConnection and leave it for the migration to attach query onto that IDbConnection using dapper or something along that line like the code below
[Migration(1,"Update user stored Proc ABC")]publicclassUpdateUserStoredProcABC:Migration{publicoverridevoidUp(){// new DbConnection api here which returns an IEnumerable<T>varusers= DbConnection.Query<string>("SELECT u.name FROM sysusers g INNER JOIN sysusers u ON g.gid = u.gid");foreach(var user in users){
Execute.Sql($"SetUser '{user}'");
Execute.Script("whatever..");}//etc...}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
@jzabroski and everyone else
Not sure if this issue has been discussed, but I felt there is need to have this interface as there are times where part of the MigrationUp() we need to query the database within the current context and set/update the migrating script according.
This interface would have a similar method signatures to
IExecuteExpressionRoot
the only difference is that those methods would return anIEnumerable<T>
The abstract class
MigrationBase
will have a new property of this interface and let's say we call it QuerySo with the above settings we can achieve something along these lines below
The alternative (not ideal) would be exposing
IDbConnection
as a property within the abstract classMigrationBase
and let's say we call it DbConnection and leave it for the migration to attach query onto thatIDbConnection
using dapper or something along that line like the code belowBeta Was this translation helpful? Give feedback.
All reactions