Azure Table Storage CreateQuery in .NET Core

前端 未结 2 1216
时光说笑
时光说笑 2021-02-07 05:23

I\'m porting my existing class library that targets .NET Framework 4.6.2 to .NET Core 1.1.

Looks like some of the methods that are available in .NET Framework version ar

2条回答
  •  春和景丽
    2021-02-07 06:05

    I'll tack these handy extension methods on to this post :)

    public static async System.Threading.Tasks.Task> ExecuteQueryAsync(this CloudTable table, TableQuery query)
    {
        TableContinuationToken token = null;
        var retVal = new List();
        do
        {
            var results = await table.ExecuteQuerySegmentedAsync(query, token);
            retVal.AddRange(results.Results);
            token = results.ContinuationToken;
        } while (token != null);
    
        return retVal;
    }
    
    public static async System.Threading.Tasks.Task> ExecuteQueryAsync(this CloudTable table, TableQuery query) where T : ITableEntity, new()
    {
        TableContinuationToken token = null;
        var retVal = new List();
        do
        {
            var results = await table.ExecuteQuerySegmentedAsync(query, token);
            retVal.AddRange(results.Results);
            token = results.ContinuationToken;
        } while (token != null);
    
        return retVal;
    }
    

    They give you back the same functionality but with ExecuteQueryASYNC as the method name

提交回复
热议问题