Azure Table 泛型 - ExecuteQuery 不支持操作

Azure Table Generics - Operation not supported on ExecuteQuery

我正在尝试为 Azure 表创建通用实现。问题是,当我使用 ExecuteQuery 函数时,它总是 return 给我以下错误:

Error = Unable to evaluate the expression. Operation not supported. Unknown error: 0x80070057.

我可以运行 TableOperation 的执行函数,例如删除、更新、创建、检索

这是我在项目中创建的 classes:

基地class

public abstract class TableEntityBase : TableEntity
{
    private string TableName { get; set; }

    public TableEntityBase(string tableName)
    {
        TableName = tableName;
    }

    public string GetTableName() => TableName;
}

然后是它的界面

public interface ITableEntityBase<T> where T : TableEntityBase
{    
    TableResult InsertOrMerge(T entity);

    TableResult Delete(T id);

    IEnumerable<T> GetByExpression(string query);

    IEnumerable<T> GetAll();
}

我的表 classes

public class Mapping : TableEntityBase
{
    public Mapping() :
            base(EntityLogicalName)
    {
    }

    private const string EntityLogicalName = "Mapping";
    public string Source { get; set; }
}

public interface IMapping : ITableEntityBase<Mapping>
{
}

至少,我的服务class

public class TableEntityBaseServices<T> : ITableEntityBase<T> where T : TableEntityBase, new()
{
    protected CloudTable _cloudTable;
    protected string tableName = ((T)Activator.CreateInstance(typeof(T))).GetTableName();

    public TableEntityBaseServices()
    {
        IConfiguration appSettings = AppSettings.GetAppSettings().GetSection("ConnectionStrings");
        _cloudTable = CloudStorageAccountExtensions.CreateCloudTableClient(CloudStorageAccount.Parse(appSettings.GetSection("AzureConfig").Value)).GetTableReference(tableName);
        _cloudTable.CreateIfNotExistsAsync();
    }

//...Other methods that work well

        IEnumerable<T> ITableEntityBase<T>.GetByExpression(string query)
        {
            return _cloudTable.ExecuteQuery<T>(new TableQuery<T>().Where(query)); //Error here: Unable to evaluate the expression. Operation not supported.
        }
    }

地图服务则为:

    public class MappingServices : TableEntityBaseServices<Mapping>, IMapping {       }

方法调用要简单

    static async Task Main(string[] args)
    {
        var serviceProvider = new ServiceCollection()
                            .AddSingleton<IMapping, MappingServices>()
                            .BuildServiceProvider();

        IMapping _mappingService = serviceProvider.GetRequiredService<IMapping>();

        try
        {
            IEnumerable<Mapping> mappings  = _mappingService.GetByExpression(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "test1"));
        }
        catch (Exception e)
        {
            throw e;
        }
    }

我看到了 个问题,但在我的情况下,我不知道我需要做什么,因为我已经在我的服务 class 上定义了 new()。我哪里搞砸了?

提前致谢:)

如果不是,请使用包 Microsoft.Azure.Cosmos.Table 1.0.8

我正在使用您的代码进行测试,没有出现错误。测试结果如下: