一,引言

  上一篇文章我们在.NET 项目中添加了 “WindowsAzure.Storage” 的 NuGet 包进行操作Table 数据,但是使用的 “WindowsAzure.Storage”  NeGet 以及没微遗弃了,所以我们今天继续讲 Azure Table Storage,使用新的 Nuget  包--- “Microsoft.Azure.Cosmos.Table” 来操作 Table 数据。

nuget 链接:https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Table

我们可以看到 当前neget 包 允许使用 Microsoft Azure CosmosDB 表 API 以及 Azure 表存储。

Azure Storage 系列(五)通过Azure.Cosmos.Table 类库在.Net 上使用 Table Storage

--------------------我是分割线--------------------

Azure Blob Storage 存储系列:

1,Azure Storage 系列(一)入门简介

2,Azure Storage 系列(二) .NET Core Web 项目中操作 Blob 存储

3,Azure Storage 系列(三)Blob 参数设置说明

4,Azure Storage 系列(四)在.Net 上使用Table Storage

5,Azure Storage 系列(五)通过Azure.Cosmos.Table 类库在.Net 上使用 Table Storage  

6,Azure Storage 系列(六)使用Azure Queue Storage

二,正文

1,安装 “Microsoft.Azure.Cosmos.Table” 的 NuGet

 Azure Storage 系列(五)通过Azure.Cosmos.Table 类库在.Net 上使用 Table Storage

 使用程序包管理控制台进行安装

Install-Package Microsoft.Azure.Cosmos.Table -Version 1.0.8

2,创建ITableServiceV2 接口,和 TableServiceV2 实现类,控制器方法等

  因为使用的 “Microsoft.Azure.Cosmos.Table” 的Nuget 和 “WindowsAzure.Storage” Nuget 中对 Table Storage 的操作中使用的方法,以及类都是一样的,只是命名空间不一样,所以代码上差别不太大。所以大家可以看一下具体代码和已遗弃的方法进行对比。

完整代码:

 1 public interface ITableServiceV2
 2     {
 3         /// <summary>
 4         /// AddEntity(abandoned)
 5         /// </summary>
 6         /// <param name="user">user</param>
 7         /// <returns></returns>
 8         Task AddEntity(UserInfoV2 user);
 9 
10         /// <summary>
11         /// BatchAddEntities(abandoned)
12         /// </summary>
13         /// <param name="users">users</param>
14         /// <returns></returns>
15         Task BatchAddEntities(List<UserInfoV2> users);
16 
17         /// <summary>
18         /// QueryUsers(abandoned)
19         /// </summary>
20         /// <param name="filter">filter</param>
21         /// <returns></returns>
22         IEnumerable<UserInfoV2> QueryUsers(string filter);
23 
24         /// <summary>
25         /// UpdateEntity(abandoned)
26         /// </summary>
27         /// <param name="user">user</param>
28         /// <returns></returns>
29         Task UpdateEntity(UserInfoV2 user);
30 
31         /// <summary>
32         /// DeleteEntity(abandoned)
33         /// </summary>
34         /// <param name="user">user</param>
35         /// <returns></returns>
36         Task DeleteEntity(UserInfoV2 user);
37 
38         /// <summary>
39         /// DeleteTable(abandoned)
40         /// </summary>
41         /// <param name="tableName">tableName</param>
42         /// <returns></returns>
43         Task DeleteTable(string tableName);
44     }
ITableServiceV2.cs

相关文章:

  • 2021-10-05
  • 2022-12-23
  • 2021-11-30
  • 2021-07-17
  • 2021-12-22
  • 2021-10-07
  • 2022-12-23
猜你喜欢
  • 2022-02-06
  • 2021-11-02
  • 2021-11-15
  • 2021-09-08
  • 2021-07-06
  • 2021-08-10
相关资源
相似解决方案