{"id":22928074,"url":"https://github.com/ttakahari/adonetprofiler","last_synced_at":"2025-05-13T01:51:26.789Z","repository":{"id":144169787,"uuid":"44588702","full_name":"ttakahari/AdoNetProfiler","owner":"ttakahari","description":"Profiling database access with ADO.NET","archived":false,"fork":false,"pushed_at":"2020-06-25T12:42:44.000Z","size":1198,"stargazers_count":12,"open_issues_count":2,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-21T11:42:41.253Z","etag":null,"topics":["ado","csharp","profile"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttakahari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-20T07:11:49.000Z","updated_at":"2021-08-05T06:08:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6dacde2-ada3-445a-ad6f-a25edbc33400","html_url":"https://github.com/ttakahari/AdoNetProfiler","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttakahari%2FAdoNetProfiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttakahari%2FAdoNetProfiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttakahari%2FAdoNetProfiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttakahari%2FAdoNetProfiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttakahari","download_url":"https://codeload.github.com/ttakahari/AdoNetProfiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856617,"owners_count":21974576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ado","csharp","profile"],"created_at":"2024-12-14T09:17:16.579Z","updated_at":"2025-05-13T01:51:26.774Z","avatar_url":"https://github.com/ttakahari.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AdoNetProfiler\n\nProfiler for ADO.NET with hooking ```DbConnection```, ```DbCommand```, ```DbDataReader```, ```DbTransaction```.\nAlthough threre is already \u003ca href=\"\"\u003eMiniProfiler\u003c/a\u003e as similar, I make this because I think it lacks hook points.\nAdoNetProfiler can profile the state of ```DbConnection```, ```DbCommand``` and ```DbTransaction```.\n\n[![AppVeyor](https://img.shields.io/appveyor/ci/gruntjs/grunt.svg?style=plastic)](https://ci.appveyor.com/project/ttakahari/adonetprofiler)\n[![NuGet](https://img.shields.io/nuget/v/AdoNetProfiler.svg?style=plastic)](https://www.nuget.org/packages/AdoNetProfiler/)\n\n## Install\n\nfrom NuGet - \u003ca href=\"https://www.nuget.org/packages/AdoNetProfiler/\"\u003eAdoNetProfiler\u003c/a\u003e\n\n```ps1\nPM \u003e Install-Package AdoNetProfiler\n```\n\n## How to use\n\nIn stead of creating the connection instance directly from ```SqlConnection``` or others, create from ```AdoNetProfilerDbConnection``` with giving the original connection instance and your profiler implementing ```IAdoNetProfiler``` as arguments.\n\n```csharp\nusing (var connection = new AdoNetProfilerConnection(new SqlConnection(\"Your connection string\"), new YourProfiler()))\n{\n    // write data-access logics here.\n}\n```\n\nOr, if initalizing ```AdoNetProfilerFactory``` when the application starts, it is available from ```DbProviderFctories```.\n\n```csharp\n// when the application starts.\nAdoNetProfilerFactory.Inialize(typeof(YourProfiler)).\n\n// data-access logic\nvar factory = DbProviderFactories.GetFactory(\"System.Data.SqlClient\").\nusing (var connection = factory.CreateConnection())\n{\n    connection.ConnectionString = \"[Your connection string]\";\n\n    // write data-access logics here.\n}\n```\n\n## Profiler\n\n```IAdoNetProfiler``` has the following contents.\n\n```csharp\n/// \u003csummary\u003e\n/// The interface that defines methods profiling of database accesses.\n/// \u003c/summary\u003e\npublic interface IAdoNetProfiler\n{\n    /// \u003csummary\u003e\n    /// Get the profiler is enabled or not.\n    /// \u003c/summary\u003e\n    bool IsEnabled { get; }\n        \n    /// \u003csummary\u003e\n    /// Execute before the connection open.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnOpening(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute after the connection open.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnOpened(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute before the connection close.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnClosing(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute after the connection close.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnClosed(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute before the connection creates the transaction.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnStartingTransaction(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute after the connection creates the transaction.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"transaction\"\u003eThe created transaction.\u003c/param\u003e\n    void OnStartedTransaction(DbTransaction transaction);\n\n    /// \u003csummary\u003e\n    /// Execute before the transaction commits.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"transaction\"\u003eThe current transaction.\u003c/param\u003e\n    void OnCommitting(DbTransaction transaction);\n\n    /// \u003csummary\u003e\n    /// Execute after the transaction commits.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnCommitted(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute before the transaction rollbacks.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"transaction\"\u003eThe current transaction.\u003c/param\u003e\n    void OnRollbacking(DbTransaction transaction);\n\n    /// \u003csummary\u003e\n    /// Execute after the transaction rollbacks.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"connection\"\u003eThe current connection.\u003c/param\u003e\n    void OnRollbacked(DbConnection connection);\n\n    /// \u003csummary\u003e\n    /// Execute before \u003csee cref=\"DbCommand.ExecuteReader()\"/\u003e executes.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"command\"\u003eThe executing command.\u003c/param\u003e\n    void OnExecuteReaderStart(DbCommand command);\n\n    /// \u003csummary\u003e\n    /// Execute after \u003csee cref=\"DbDataReader\"/\u003e reads.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"reader\"\u003eThe stream from data source.\u003c/param\u003e\n    /// \u003cparam name=\"record\"\u003eThe number of read data.\u003c/param\u003e\n    void OnReaderFinish(DbDataReader reader, int record);\n\n    /// \u003csummary\u003e\n    /// Execute before \u003csee cref=\"DbCommand.ExecuteNonQuery\"/\u003e executes.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"command\"\u003eThe executing command.\u003c/param\u003e\n    void OnExecuteNonQueryStart(DbCommand command);\n\n    /// \u003csummary\u003e\n    /// Execute after \u003csee cref=\"DbCommand.ExecuteNonQuery\"/\u003e executes.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"command\"\u003eThe executing command.\u003c/param\u003e\n    /// \u003cparam name=\"executionRestlt\"\u003eThe result of executing \u003csee cref=\"DbCommand.ExecuteNonQuery\"/\u003e.\u003c/param\u003e\n    void OnExecuteNonQueryFinish(DbCommand command, int executionRestlt);\n\n    /// \u003csummary\u003e\n    /// Execute before \u003csee cref=\"DbCommand.ExecuteScalar\"/\u003e executes.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"command\"\u003eThe executing command.\u003c/param\u003e\n    void OnExecuteScalarStart(DbCommand command);\n\n    /// \u003csummary\u003e\n    /// Execute after \u003csee cref=\"DbCommand.ExecuteScalar\"/\u003e executes.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"command\"\u003eThe executing command.\u003c/param\u003e\n    /// \u003cparam name=\"executionRestlt\"\u003eThe result of executing \u003csee cref=\"DbCommand.ExecuteScalar\"/\u003e.\u003c/param\u003e\n    void OnExecuteScalarFinish(DbCommand command, object executionRestlt);\n\n    /// \u003csummary\u003e\n    /// Execute when the error occurs while the command executing.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"command\"\u003eThe executing command.\u003c/param\u003e\n    /// \u003cparam name=\"exception\"\u003eThe occurred error.\u003c/param\u003e\n    void OnCommandError(DbCommand command, Exception exception);\n}\n```\n\nImplementing this interface, you can get your profiler.\n\nAn instance of `IAdoNetProfiler` is not thread-safe. So you should not use an instance of `IAdoNetProfiler` among some instances of `DbConnection`.\n\n## Entity Framework\n\nAdoNerProfiler does not support Entity Framework. When you use AdoNetProfiler with Entity Framework in a same project, some errors may occur becouse of conflicting.\n\n## Glimpse\n\n\u003ca href=\"http://getglimpse.com/\"\u003eGlimpse\u003c/a\u003e is profiling library for ASP.NET.\n\nAdoNetProfiler has the library for Glimpse.\n\nfrom NuGet - \u003ca href=\"https://www.nuget.org/packages/Glimpse.AdoNetProfiler/\"\u003eGlimpse.AdoNetProfiler\u003c/a\u003e\n\n```ps1\nPM \u003e Install-Package Glimpse.AdoNetProfiler\n```\n\nGlimpse.Ado, that has already been provided as a part of Glimpse libaries, displays SQL profilings.\n\nBut Glimpse.AdoNetProfiler displays connection and transaction profilings, to say nothing of SQL.\n\n\u003cimg src=\"https://github.com/ttakahari/AdoNetProfiler/blob/master/docs/timeline.png\" /\u003e\n\n\u003cimg src=\"https://github.com/ttakahari/AdoNetProfiler/blob/master/docs/command.png\" /\u003e\n\n\u003cimg src=\"https://github.com/ttakahari/AdoNetProfiler/blob/master/docs/connection.png\" /\u003e\n\n\u003cimg src=\"https://github.com/ttakahari/AdoNetProfiler/blob/master/docs/transaction.png\" /\u003e\n\n## Lisence\n\nunder \u003ca href=\"http://opensource.org/licenses/MIT\"\u003eMIT License\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttakahari%2Fadonetprofiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttakahari%2Fadonetprofiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttakahari%2Fadonetprofiler/lists"}