{"id":22882314,"url":"https://github.com/loresoft/tablestorage.abstracts","last_synced_at":"2025-05-07T04:47:25.449Z","repository":{"id":232443092,"uuid":"783798740","full_name":"loresoft/TableStorage.Abstracts","owner":"loresoft","description":"Azure Table Storage Abstracts library defines abstract base classes for repository pattern.","archived":false,"fork":false,"pushed_at":"2025-05-06T07:36:43.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T04:47:09.279Z","etag":null,"topics":["azure-storage","azure-table-storage","repository-pattern","storage"],"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/loresoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"loresoft"}},"created_at":"2024-04-08T15:37:20.000Z","updated_at":"2025-05-06T07:36:39.000Z","dependencies_parsed_at":"2024-04-10T23:27:20.570Z","dependency_job_id":"617f4755-c730-4665-b4d4-73dadc3a69c1","html_url":"https://github.com/loresoft/TableStorage.Abstracts","commit_stats":null,"previous_names":["loresoft/tablestorage.abstracts"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FTableStorage.Abstracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FTableStorage.Abstracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FTableStorage.Abstracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loresoft%2FTableStorage.Abstracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loresoft","download_url":"https://codeload.github.com/loresoft/TableStorage.Abstracts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816522,"owners_count":21808702,"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":["azure-storage","azure-table-storage","repository-pattern","storage"],"created_at":"2024-12-13T18:16:54.491Z","updated_at":"2025-05-07T04:47:25.425Z","avatar_url":"https://github.com/loresoft.png","language":"C#","readme":"# TableStorage.Abstracts\n\nAzure Table Storage Abstracts library defines abstract base classes for repository pattern.\n\n[![Build status](https://github.com/loresoft/TableStorage.Abstracts/workflows/Build/badge.svg)](https://github.com/loresoft/TableStorage.Abstracts/actions)\n\n[![NuGet Version](https://img.shields.io/nuget/v/TableStorage.Abstracts.svg?style=flat-square)](https://www.nuget.org/packages/TableStorage.Abstracts/)\n\n[![Coverage Status](https://coveralls.io/repos/github/loresoft/TableStorage.Abstracts/badge.svg?branch=main)](https://coveralls.io/github/loresoft/TableStorage.Abstracts?branch=main)\n\n## Download\n\nThe TableStorage.Abstracts library is available on nuget.org via package name `TableStorage.Abstracts`.\n\nTo install TableStorage.Abstracts, run the following command in the Package Manager Console\n\n```powershell\nInstall-Package TableStorage.Abstracts\n```\n\nMore information about NuGet package available at\n\u003chttps://nuget.org/packages/TableStorage.Abstracts\u003e\n\n## Features\n\n- find one, many and by paged results\n- create, update and delete pattern\n- batch processing for bulk insert/update\n- table initialization on first use\n\n## Usage\n\n### Dependency Injection\n\nRegister services with the Azure storage connection string named 'AzureStorage' loaded from configuration\n\n```c#\nservices.AddTableStorageRepository(\"AzureStorage\");\n```\n\nExample appsettings.json file\n\n```json\n{\n  \"AzureStorage\": \"UseDevelopmentStorage=true\"\n}\n```\n\nRegister with the Azure storage connection string passed in\n\n```c#\nservices.AddTableStorageRepository(\"UseDevelopmentStorage=true\");\n```\n\nResolve `ITableRepository\u003cT\u003e`\n\n```c#\nvar repository = serviceProvider.GetRequiredService\u003cITableRepository\u003cItem\u003e\u003e();\n```\n\nResolve `TableServiceClient`\n\n```c#\nvar tableServiceClient = serviceProvider.GetRequiredService\u003cTableServiceClient\u003e();\n```\n\n### Custom Repository\n\nCreate a custom repository instance by inheriting `TableRepository\u003cT\u003e`\n\n```c#\npublic class UserRepository : TableRepository\u003cUser\u003e\n{\n    public UserRepository(ILoggerFactory logFactory, TableServiceClient tableServiceClient)\n        : base(logFactory, tableServiceClient)\n    { }\n\n    protected override void BeforeSave(User entity)\n    {\n        // use email as partition key\n        entity.PartitionKey = entity.Email;\n\n        base.BeforeSave(entity);\n    }\n\n    // uses typeof(TEntity).Name by default, override with custom table name\n    protected override string GetTableName() =\u003e \"UserMembership\";\n}\n```\n\n### Query Operations\n\nFind an entity by row and partition key.  Note, table storage requires both.\n\n```c#\nvar repository = serviceProvider.GetRequiredService\u003cITableRepository\u003cItem\u003e\u003e();\nvar readResult = await repository.FindAsync(rowKey, partitionKey);\n```\n\nFind all by filter expression\n\n```c#\nvar queryResults = await repository.FindAllAsync(r =\u003e r.IsActive);\n```\n\nFind all by filter expression\n\n```c#\nvar itemResult = await repository.FindOneAsync(r =\u003e r.Name == itemName);\n```\n\nFind a page of items by filter.  Note, Azure Table storage only supports forward paging by Continuation Token.\n\n```c#\nvar pageResult = await repository.FindPageAsync(\n    filter: r =\u003e r.IsActive,\n    pageSize: 20);\n\n// loop through pages\nwhile (!string.IsNullOrEmpty(pageResult.ContinuationToken))\n{\n    // get next paging using previous continuation token\n    pageResult = await repository.FindPageAsync(\n        filter: r =\u003e r.IsActive,\n        continuationToken: pageResult.ContinuationToken,\n        pageSize: 20);\n}\n```\n\n### Update Operations\n\nCreate an item\n\n```c#\n var createdItem = await repository.CreateAsync(item);\n```\n\nUpdate an item\n\n```c#\n var updatedItem = await repository.UpdateAsync(item);\n```\n\nSave or Upsert an item\n\n```c#\n var savedItem = await repository.SaveAsync(item);\n```\n\n#### RowKey and PartitionKey\n\nAzure Table Storage requires both a `RowKey` and `PartitionKey`\n\nThe base repository will set the `RowKey` if it hasn't already been set using the `NewRowKey()` method.  The default implementation is `Ulid.NewUlid().ToString()`\n\nIf `PartitionKey` hasn't been set, `RowKey` will be used.\n\n### Batch Operations\n\nBulk insert data\n\n```c#\nawait repository.BatchAsync(items);\n```\n\nBatch Merge data\n\n```c#\nawait repository.BatchAsync(items, TableTransactionActionType.UpdateMerge);\n```\n","funding_links":["https://github.com/sponsors/loresoft"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floresoft%2Ftablestorage.abstracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floresoft%2Ftablestorage.abstracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floresoft%2Ftablestorage.abstracts/lists"}