2016-07-07 61 views
1

下面的擴展方法不會在我的ASP.NET Core項目中編譯,並且Visual Studio突出顯示方法ExecuteQuerySegmentedAsync作爲問題。錯誤(代碼下方)引用了我不想要的方法簽名。我想要這個hereAzure存儲表擴展方法中的ExecuteQuerySegmentedAsync調用錯誤

internal static class CloudTableExtensions 
{ 
     public static async Task<IList<DynamicTableEntity>> ExecuteQueryAsync(this CloudTable table, 
      TableQuery query, CancellationToken cancellationToken = default(CancellationToken)) 
    { 
     var items = new List<DynamicTableEntity>(); 
     TableContinuationToken token = null; 
     do 
     { 
      var seg = await table.ExecuteQuerySegmentedAsync(query, token, cancellationToken); 

      token = seg.ContinuationToken; 
      items.AddRange(seg); 


     } while (token != null && !cancellationToken.IsCancellationRequested 
      && (query.TakeCount == null || items.Count < query.TakeCount.Value)); 


     return items; 
    } 
} 

的錯誤是: Error CS0411 The type arguments for method 'CloudTable.ExecuteQuerySegmentedAsync<T, TResult>(TableQuery<T>, EntityResolver<TResult>, TableContinuationToken)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

+0

是否使用.NET核心的最新版本?你正在使用哪個版本的windowsazure.storage? – Thomas

+0

是的我正在使用ASP.NET Core 1.0.0和WindowsAzure.Storage 7.1.3-Preview –

回答

1

WindowsAzure.Storage 7.1.3-Preview NuGet包的ASP.NET核心1.0.0 不包含ExecuteQuerySegmentedAsync功能與此簽名。 也許你應該在github repo上爲此創建一個問題。

否則,如果您需要通過取消標記,你可以使用this

internal static class CloudTableExtensions 
{ 
    public static async Task<IList<DynamicTableEntity>> ExecuteQueryAsync(this CloudTable table, 
     TableQuery query, CancellationToken cancellationToken = default(CancellationToken)) 
    { 
     var items = new List<DynamicTableEntity>(); 
     TableContinuationToken token = null; 
     do 
     { 
      var seg = 
       await 
        table.ExecuteQuerySegmentedAsync(query, token, new TableRequestOptions(), new OperationContext(), 
         cancellationToken); 

      token = seg.ContinuationToken; 
      items.AddRange(seg); 


     } while (token != null && !cancellationToken.IsCancellationRequested 
       && (query.TakeCount == null || items.Count < query.TakeCount.Value)); 


     return items; 
    } 
}