{"id":21654607,"url":"https://github.com/kros-sk/kros.utils.msaccess","last_synced_at":"2025-04-11T21:14:01.077Z","repository":{"id":48831358,"uuid":"177123064","full_name":"Kros-sk/Kros.Utils.MsAccess","owner":"Kros-sk","description":"General library of various utilities to simplify the work of a programmer with Microsoft Access databases.","archived":false,"fork":false,"pushed_at":"2024-01-16T19:24:19.000Z","size":306,"stargazers_count":9,"open_issues_count":6,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T21:13:54.878Z","etag":null,"topics":["dot-net","dotnet","ms-access","msaccess","utilities","utility","utils"],"latest_commit_sha":null,"homepage":"","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/Kros-sk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2019-03-22T10:49:00.000Z","updated_at":"2024-10-10T04:13:58.000Z","dependencies_parsed_at":"2024-11-25T08:39:31.801Z","dependency_job_id":null,"html_url":"https://github.com/Kros-sk/Kros.Utils.MsAccess","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kros-sk%2FKros.Utils.MsAccess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kros-sk%2FKros.Utils.MsAccess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kros-sk%2FKros.Utils.MsAccess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kros-sk%2FKros.Utils.MsAccess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kros-sk","download_url":"https://codeload.github.com/Kros-sk/Kros.Utils.MsAccess/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480427,"owners_count":21110937,"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":["dot-net","dotnet","ms-access","msaccess","utilities","utility","utils"],"created_at":"2024-11-25T08:28:25.568Z","updated_at":"2025-04-11T21:14:01.048Z","avatar_url":"https://github.com/Kros-sk.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kros.Utils.MsAccess [![Build Status](https://dev.azure.com/krossk/DevShared/_apis/build/status/Kros.Utils/Kros.Utils.MsAccess?branchName=features/buildAndPush)](https://dev.azure.com/krossk/DevShared/_build/latest?definitionId=65\u0026branchName=master)\n\n__Kros.Utils.MsAccess__ is a general library of various utilities to simplify the work of a programmer with Microsoft Access databases.\n\nFor some (especially database) stuff to work properly, the library needs to be initialized when the program starts by calling [LibraryInitializer.InitLibrary](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Utils.MsAccess.LibraryInitializer.html#Kros_Utils_MsAccess_LibraryInitializer_InitLibrary \"LibraryInitializer InitLibrary\").\n\nLibrary is compiled for .NET Framework 4.6.\n\n## Documentation\n\nFor configuration, general information and examples [see the documentation](https://kros-sk.github.io/docs/Kros.Utils.MsAccess/).\n\n## Download\n\nKros.Libs is available from __Nuget__ [__Kros.Utils.MsAccess__](https://www.nuget.org/packages/Kros.Utils.MsAccess/)\n\n## Contributing Guide\n\nTo contribute with new topics/information or make changes, see [contributing](https://github.com/Kros-sk/Kros.Utils.MsAccess/blob/master/CONTRIBUTING.md) for instructions and guidelines.\n\n## This topic contains following sections\n\n__Kros.Utils.MsAccess__\n\n* [General Utilities](#msaccess-general-utilities)\n* [Database Schema](#msaccess-database-schema)\n* [Bulk Operations - Bulk Insert and Bulk Update](#msaccess-bulk-operations---bulk-insert-and-bulk-update)\n* [Unit Testing Helpers](#msaccess-unit-testing-helpers)\n\n### MsAccess General Utilities\n\nThe [MsAccessDataHelper](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Data.MsAccess.MsAccessDataHelper.html \"MsAccessDataHelper\") class contains general utilities for working with the MS Access database connection.\n\n* Retrieve current MS Access provider: [MsAccessProvider](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Data.MsAccess.MsAccessDataHelper.html#Kros_Data_MsAccess_MsAccessDataHelper_MsAccessAceProvider \"MsAccessProvider\")\n* Determining whether the connection to the MS Access database is exclusive: [IsExclusiveMsAccessConnection](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Data.MsAccess.MsAccessDataHelper.html#Kros_Data_MsAccess_MsAccessDataHelper_IsExclusiveMsAccessConnection_System_Data_IDbConnection_ \"IsExclusiveMsAccessConnection\")\n* Determining whether the connection is a connection to the MS Access database: [IsMsAccessConnection](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Data.MsAccess.MsAccessDataHelper.html#Kros_Data_MsAccess_MsAccessDataHelper_IsMsAccessConnection_System_Data_IDbConnection_ \"IsMsAccessConnection\")\n\n### MsAccess Database Schema\n\nIt is very easy to get a database schema. Since the acquisition of the schema is a time-consuming operation the loaded scheme is held in a cache and the next schema is retrieved. The database schema includes the [TableSchema](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.Schema.TableSchema.html \"TableSchema\") tables, their [ColumnSchema](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.Schema.ColumnSchema.html \"ColumnSchema\") columns and [IndexSchema](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.Schema.IndexSchema.html \"IndexSchema\") indexes.\n\n```c#\nOleDbConnection cn = new OleDbConnection(\"MS Access Connection String\");\n\nDatabaseSchema schema = DatabaseSchemaLoader.Default.LoadSchema(cn);\n```\n\n### MsAccess Bulk Operations - Bulk Insert and Bulk Update\n\nInserting (`INSERT`) and updating (`UPDATE`) large amounts of data in a database are time-consuming. Therefore, support for rapid mass insertion, `Bulk Insert` and a fast bulk update, `Bulk Update`. The [IBulkInsert](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.BulkActions.IBulkInsert.html \"IBulkInsert\") and [IBulkUpdate](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.BulkActions.IBulkUpdate.html \"IBulkUpdate\") interfaces are used. They are implemented for MsAccess database in the [MsAccessBulkInsert](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Data.BulkActions.MsAccess.MsAccessBulkInsert.html \"MsAccessBulkInsert\") and [MsAccessBulkUpdate](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.Data.BulkActions.MsAccess.MsAccessBulkUpdate.html \"MsAccessBulkUpdate\") classes. As a data source, it serves any [IDataReader](https://msdn.microsoft.com/en-us/library/sh674a6a \"IDataReader\") or [DataTable](https://msdn.microsoft.com/en-us/library/9186hy08 \"DataTable\") table.\n\nBecause `IDataReader` is an intricate interface, you just need to implement the simplier interface [IBulkActionDataReader](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.BulkActions.IBulkActionDataReader.html \"IBulkActionDataReader\"). If the source is a list (`IEnumerable`), it is sufficient to use the [`EnumerableDataReader\u003cT\u003e`](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils/Kros.Data.BulkActions.EnumerableDataReader-1.html \"EnumerableDataReader\u003cT\u003e\") class for its bulk insertion.\n\n```c#\nprivate class Item\n{\n    public int Id { get; set; }\n    public string Name { get; set; }\n}\n\npublic void InsertManyItems()\n{\n    IEnumerable\u003cItem\u003e data = GetData();\n\n    using (var reader = new EnumerableDataReader\u003cItem\u003e(data, new string[] { \"Id\", \"Name\" }))\n    {\n        using (var bulkInsert = new MsAccessBulkInsert(\"connection string\"))\n        {\n            bulkInsert.Insert(reader);\n        }\n    }\n}\n```\n\n### MsAccess Unit Testing Helpers\n\nStandard unit tests should be database-independent. But sometimes it is necessary to test the actual database because the test items are directly related to it. To test the actual database you can use the [MsAccessTestHelper](https://kros-sk.github.io/Kros.Libs.Documentation/api/Kros.Utils.MsAccess/Kros.UnitTests.MsAccessTestHelper.html \"MsAccessTestHelper\") class. It creates a database for testing purposes on the server and runs tests over it. When tests are finished the database is deleted.\n\n```c#\nprivate const string BaseDatabasePath = \"C:\\testfiles\\testdatabase.accdb\";\n\nprivate const string CreateTestTableScript =\n@\"CREATE TABLE [TestTable] (\n    [Id] number NOT NULL,\n    [Name] text(255) NULL,\n\n    CONSTRAINT [PK_TestTable] PRIMARY KEY ([Id])\n)\";\n\n[Fact]\npublic void DoSomeTestWithDatabase()\n{\n    using (var helper = new MsAccessTestHelper(ProviderType.Ace, BaseDatabasePath, CreateTestTableScript))\n    {\n        // Do tests with connection helper.Connection.\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkros-sk%2Fkros.utils.msaccess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkros-sk%2Fkros.utils.msaccess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkros-sk%2Fkros.utils.msaccess/lists"}