{"id":22065541,"url":"https://github.com/karenpayneoregon/dataprovidercommandhelpers","last_synced_at":"2025-07-22T01:34:49.688Z","repository":{"id":110840476,"uuid":"169908323","full_name":"karenpayneoregon/DataProviderCommandHelpers","owner":"karenpayneoregon","description":"Used to reveal values from a well formed parameterized query","archived":false,"fork":false,"pushed_at":"2019-02-09T20:25:34.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-18T07:14:26.119Z","etag":null,"topics":["csharp","sql","vbnet"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karenpayneoregon.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-02-09T20:05:49.000Z","updated_at":"2021-06-25T02:12:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"123daf8f-03f1-4e70-82bd-ef41d394a785","html_url":"https://github.com/karenpayneoregon/DataProviderCommandHelpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/karenpayneoregon/DataProviderCommandHelpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FDataProviderCommandHelpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FDataProviderCommandHelpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FDataProviderCommandHelpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FDataProviderCommandHelpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karenpayneoregon","download_url":"https://codeload.github.com/karenpayneoregon/DataProviderCommandHelpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2FDataProviderCommandHelpers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266409669,"owners_count":23924287,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csharp","sql","vbnet"],"created_at":"2024-11-30T19:19:26.488Z","updated_at":"2025-07-22T01:34:49.639Z","avatar_url":"https://github.com/karenpayneoregon.png","language":"C#","readme":"# Data Provider Command Helpers\nThis repository contains a language extension method to reveal a parameterized SQL statement written using a managed data provider in C# or VB.NET programming languages.\n\n### NuGet command installation\nInstall-Package DataProviderCommandHelpers -Version 1.0.0\n### Instructions\n1 Add this package to your Visual Studio Solution.\n- Call RevealCommandQuery where cmd is a command object Console.WriteLine(cmd.RevealCommandQuery());\n- Call RevealCommandQueryToFile where cmd is a command object RevealCommandQueryToFile(\"SomeFile.txt\");\n\nIf not using SQL-Server, you need to pass in a database type as the last parameter of the above extension methods.\n\n```csharp\npublic enum CommandProvider\n{\n    SqlServer,\n    Access,\n    Oracle\n}\n```\n### MS-Access\nAlthough parameters use **?** for parameter markers the **@** character can be used also but since MS-Access parameters are positional parameters that are named must remain positional.\n\n\n#### Example 1\nA developer writes, in this case a SELECT statement with multiple WHERE conditions which was written in SSMS (SQL-Server Management Studio) which was tested and worked as expected.\n\nIn production customers complain when applying values for country and contact type nothing is being returned yet know there are records which match their conditions.\n\nHow can this be diagnosed when the customers are not local? Using RevealCommandQuery extension method the application can be setup to write the resulting query to a text file or email'd to the developer for figuring out why the query failed.\n\nThere are many reasons for failure but in this case the developer provided ComboBox controls to allow a \nuser to select values for the WHERE condition and as many developer do did not set the drop down type of the \nComboBoxes which allow the customer to alter a selection which does not exists thus returning no records. For simple SELECT, UPDATE, DELETE or INSERT queries this extension may not seem worthy of use yet for queries such as the one below or large is where these extensions shine.\n\n```csharp\npublic DataTable ReadSpecificCustomers(string contactTitle, string countryName, bool exposeCommandText = false)\n{\n\n    var dt = new DataTable();\n\n    var selectStatement = \n        \"SELECT Cust.CustomerIdentifier ,Cust.CompanyName ,\" + \n        \"Cust.ContactName ,Cust.ContactIdentifier , Cust.ContactTypeIdentifier ,\" + \n        \"Cust.CountryIdentfier ,C.id ,C.CountryName ,ct.ContactTypeIdentifier AS ctIdentifier ,\" + \n        \"ct.ContactTitle FROM   dbo.Customers AS Cust \" + \n        \"INNER JOIN dbo.ContactType AS ct ON Cust.ContactTypeIdentifier = ct.ContactTypeIdentifier \" + \n        \"INNER JOIN dbo.Countries AS C ON Cust.CountryIdentfier = C.id \" + \n        \"WHERE  ct.ContactTitle = @ContactTitle AND C.CountryName = @CountryName;\";\n\n    using (var cn = new SqlConnection { ConnectionString = ConnectionString })\n    {\n        using (var cmd = new SqlCommand { Connection = cn })\n        {\n            cmd.CommandText = selectStatement;\n            try\n            {\n                cmd.Parameters.AddWithValue(\"@ContactTitle\", contactTitle);\n                cmd.Parameters.AddWithValue(\"@CountryName\", countryName);\n\n                if (exposeCommandText)\n                {\n                    cmd.RevealCommandQueryToFile(CustomersSelectFileName);\n                }\n\n                cn.Open();\n\n                dt.Load(cmd.ExecuteReader());\n\n            }\n            catch (Exception e)\n            {\n                mHasException = true;\n                mLastException = e;\n            }\n        }\n    }\n\n    return dt;\n}\n```\n#### Example 2\nA developer write an SQL statement directly in code and when executing the query no results are returned. By using RevealCommandQuery which write the SQL statement to the IDE Output window the developer can a) create a new text file in Visual Studio, give it a .sql extension, drop the query it and run the query against the database. If there are errors the database will report them.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Fdataprovidercommandhelpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarenpayneoregon%2Fdataprovidercommandhelpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Fdataprovidercommandhelpers/lists"}