Skip to content

ziyasal-archive/EntityFramework.InterceptorEx

Repository files navigation

EntityFramework.InterceptorEx

Build status

⚠️⚠️⚠️ It requires more tests

INTRODUCTION

To Install via NuGet

Install-Package EntityFramework.InterceptorEx

NoLock Interceptor

To Register

static DbContextConstructor()
{
    DbInterception.Add(new WithNoLockInterceptor());
}

To Disable

WithNoLockInterceptor.Suppress = true;

To Debug Sql Query

string sql = WithNoLockInterceptor.CommandText

Sample Sql Query Output

SELECT [Extent1].[BlogId] AS [BlogId], [Extent1].[Name] AS [Name]  
       FROM [dbo].[Blogs] AS [Extent1] WITH (NOLOCK)  
       WHERE [Extent1].[Name] LIKE N'Lo%'

Transaction Interceptor

To Register

static DbContextConstructor()
{
    DbInterception.Add(new WithTransactionInterceptor());
}

To Disable

WithTransactionInterceptor.Suppress = true;

Sample Sql Query Output

DECLARE @errorCode INT

BEGIN TRAN

SELECT [Extent1].[BlogId] AS [BlogId], [Extent1].[Name] AS [Name]  
       FROM [dbo].[Blogs] AS [Extent1] WITH (NOLOCK)  
       WHERE [Extent1].[Name] LIKE N'Lo%'

SELECT
	@errorCode = @@ERROR
    IF (@errorCode <> 0) GOTO ERR_HANDLE_BLOCK
    COMMIT TRAN

      ERR_HANDLE_BLOCK:    IF (@errorCode <> 0) BEGIN
        ROLLBACK TRAN
END

Bugs

If you encounter a bug, performance issue, or malfunction, please add an Issue with steps on how to reproduce the problem.

TODO

  • Add more tests
  • Add more documentation

License

Code and documentation are available according to the MIT License (see LICENSE).

About

Useful EF interceptors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages