public static async Task DeleteAsync <TEntity>(this DapperHybridContext context, string schema, string table, Expression <Func <TEntity, bool> > filterExpression)
        {
            var filterParameters = new GeneratorContext();

            var connection      = context.Database.GetDbConnection();
            var deleteStatement = context.CreateSqlGenerator <TEntity>()
                                  .Delete(
                schema,
                table,
                filterExpression
                );

            var parameters = new DynamicParameters();

            foreach (var parameter in deleteStatement.Params)
            {
                parameters.Add(parameter.Key, parameter.Value);
            }

            await connection.ExecuteAsync(
                deleteStatement.Statement,
                parameters,
                transaction : context.Database.CurrentTransaction?.GetDbTransaction()
                )
            .ConfigureAwait(false);
        }
        public static async Task InsertAsync <TEntity>(this DapperHybridContext context, string schema, string table, TEntity entity)
        {
            var connection = context.Database.GetDbConnection();
            var parameters = new MappedDynamicParameters(entity);

            var statement = context.CreateSqlGenerator <TEntity>().Insert(schema, table, parameters.ColumnToParameterMapping);

            await connection.ExecuteAsync(
                statement.Statement,
                parameters,
                transaction : context.Database.CurrentTransaction?.GetDbTransaction()
                )
            .ConfigureAwait(false);
        }
        public static async Task InsertAsync <TEntity>(this DapperHybridContext context, TEntity entity)
        {
            var connection = context.Database.GetDbConnection();
            var entityType = context.Model.FindEntityType(typeof(TEntity));

            if (entityType == null)
            {
                throw new InvalidOperationException($"Entity of type {typeof(TEntity).FullName} is not registered in DbContext. Use overload with table name and schema");
            }

            var parameters = context.GetParameters(entity);
            var schema     = entityType.GetSchema();
            var table      = entityType.GetTableName();

            var statement = context.CreateSqlGenerator <TEntity>().Insert(schema, table, parameters.ColumnToParameterMapping);

            await connection.ExecuteAsync(
                statement.Statement,
                parameters,
                transaction : context.Database.CurrentTransaction?.GetDbTransaction())
            .ConfigureAwait(false);
        }