DbContextCommand.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Quadarax.Application.QLiberace.Base;
  2. using Quadarax.Foundation.Core.QConsole.Command.Base;
  3. using Quadarax.Foundation.Core.QConsole;
  4. using Quadarax.Foundation.Core.Value;
  5. using Microsoft.EntityFrameworkCore;
  6. namespace Quadarax.Application.QLiberace.Console.Commands.Base
  7. {
  8. internal abstract class DbContextCommand : AbstractCommand
  9. {
  10. #region *** Properties ***
  11. #endregion
  12. #region *** Constructor ***
  13. public DbContextCommand(Engine engine) : base(engine)
  14. {
  15. }
  16. #endregion
  17. #region *** EXECUTE ***
  18. protected override Result OnExecute()
  19. {
  20. var options = new DbContextOptions<QlbrcDbContext>();
  21. using (var context = new QlbrcDbContext(options))
  22. {
  23. return OnExecute(context);
  24. }
  25. }
  26. protected abstract Result OnExecute(QlbrcDbContext context);
  27. #endregion
  28. #region *** Private operations ***
  29. #endregion
  30. }
  31. }