【发布时间】:2014-01-10 19:26:52
【问题描述】:
我一定遗漏了一些明显的东西,但以下失败并出现编译错误:
internal static IEnumerable<T> GetEntitiesWithCommaSeparatedRowKeys<T>(
string tableName, string partitionKey,
string commaDelimitedStringOfRowKeys) where T: TableEntity
{
....
TableQuery<T> entitiesQuery = new TableQuery<T>().Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey",
QueryComparisons.Equal, partitionKey),
TableOperators.And,
AzureHelper.GetFilterConditionForCommaDelimitedStringOfRowKeys(commaDelimitedStringOfRowKeys)
));
// compile error on this line
IEnumerable<T> entities = table.ExecuteQuery<T>(entitiesQuery);
...
}
我得到的错误是:
'T' must be a non-abstract type with a public parameterless constructor
in order to use it as parameter 'TElement' in the generic type or
method 'Microsoft.WindowsAzure.Storage.Table.CloudTable.ExecuteQuery<TElement>
(Microsoft.WindowsAzure.Storage.Table.TableQuery<TElement>,
Microsoft.WindowsAzure.Storage.Table.TableRequestOptions,
Microsoft.WindowsAzure.Storage.OperationContext)'
TableEntity 显然有一个公共的无参数构造函数并且是非抽象的。 以下是我在 TableEntity 上按 F12 时来自元数据信息的对象(只是为了确保它正确解析 TableEntity 类型)。
namespace Microsoft.WindowsAzure.Storage.Table
{
public class TableEntity : ITableEntity
{
// Summary:
// Initializes a new instance of the Microsoft.WindowsAzure.Storage.Table.TableEntity
// class.
public TableEntity();
...
}
}
有什么想法吗? 仅供参考,我使用的是 Azure 客户端库 3.0.1.0。
更新:添加 linked issue 解决了类似问题
【问题讨论】:
标签: c#-4.0 azure-storage azure-table-storage