|
| 1 | +using System.Data; |
| 2 | +using System.Data.Common; |
| 3 | +using System.Threading; |
| 4 | +using System.Threading.Tasks; |
| 5 | +using LinqToDB.Common; |
| 6 | +using LinqToDB.Interceptors; |
| 7 | + |
| 8 | +namespace LinqToDB.EntityFrameworkCore.BaseTests.Interceptors |
| 9 | +{ |
| 10 | + public class TestCommandInterceptor : TestInterceptor, ICommandInterceptor |
| 11 | + { |
| 12 | + public void AfterExecuteReader(CommandEventData eventData, DbCommand command, CommandBehavior commandBehavior, DbDataReader dataReader) |
| 13 | + { |
| 14 | + HasInterceptorBeenInvoked = true; |
| 15 | + } |
| 16 | + |
| 17 | + public void BeforeReaderDispose(CommandEventData eventData, DbCommand? command, DbDataReader dataReader) |
| 18 | + { |
| 19 | + HasInterceptorBeenInvoked = true; |
| 20 | + } |
| 21 | + |
| 22 | + public Task BeforeReaderDisposeAsync(CommandEventData eventData, DbCommand? command, DbDataReader dataReader) |
| 23 | + { |
| 24 | + HasInterceptorBeenInvoked = true; |
| 25 | + return Task.CompletedTask; |
| 26 | + } |
| 27 | + |
| 28 | + public DbCommand CommandInitialized(CommandEventData eventData, DbCommand command) |
| 29 | + { |
| 30 | + HasInterceptorBeenInvoked = true; |
| 31 | + return command; |
| 32 | + } |
| 33 | + |
| 34 | + public Option<int> ExecuteNonQuery(CommandEventData eventData, DbCommand command, Option<int> result) |
| 35 | + { |
| 36 | + HasInterceptorBeenInvoked = true; |
| 37 | + return result; |
| 38 | + } |
| 39 | + |
| 40 | + public Task<Option<int>> ExecuteNonQueryAsync(CommandEventData eventData, DbCommand command, Option<int> result, CancellationToken cancellationToken) |
| 41 | + { |
| 42 | + HasInterceptorBeenInvoked = true; |
| 43 | + return Task.FromResult(result); |
| 44 | + } |
| 45 | + |
| 46 | + public Option<DbDataReader> ExecuteReader(CommandEventData eventData, DbCommand command, CommandBehavior commandBehavior, Option<DbDataReader> result) |
| 47 | + { |
| 48 | + HasInterceptorBeenInvoked = true; |
| 49 | + return result; |
| 50 | + } |
| 51 | + |
| 52 | + public Task<Option<DbDataReader>> ExecuteReaderAsync(CommandEventData eventData, DbCommand command, CommandBehavior commandBehavior, Option<DbDataReader> result, CancellationToken cancellationToken) |
| 53 | + { |
| 54 | + HasInterceptorBeenInvoked = true; |
| 55 | + return Task.FromResult(result); |
| 56 | + } |
| 57 | + |
| 58 | + public Option<object?> ExecuteScalar(CommandEventData eventData, DbCommand command, Option<object?> result) |
| 59 | + { |
| 60 | + HasInterceptorBeenInvoked = true; |
| 61 | + return result; |
| 62 | + } |
| 63 | + |
| 64 | + public Task<Option<object?>> ExecuteScalarAsync(CommandEventData eventData, DbCommand command, Option<object?> result, CancellationToken cancellationToken) |
| 65 | + { |
| 66 | + HasInterceptorBeenInvoked = true; |
| 67 | + return Task.FromResult(result); |
| 68 | + } |
| 69 | + } |
| 70 | +} |
0 commit comments