为什么我在查询TableServiceContext时收到MissingMethodException?
问题描述:
我想查询一个Azure表存储。对于我使用下面的两种方法:为什么我在查询TableServiceContext时收到MissingMethodException?
TableServiceContext:使用上述方法
public IQueryable<T> QueryEntities<T>(string tableName) where T : TableServiceEntity
{
this.ResolveType = (unused) => typeof(T);
return this.CreateQuery<T>(tableName);
}
代码:
CloudStorageAccount account = AzureConnector.GetCloudStorageAccount(AppSettingsVariables.TableStorageConnection);
AzureTableStorageContext context = new AzureTableStorageContext(account.TableEndpoint.ToString(), account.Credentials);
// Checks if the setting already exists in the Azure table storage. Returns null if not exists.
var existsQuery = from e in context.QueryEntities<ServiceSettingEntity>(TableName)
where e.ServiceName.Equals(this.ServiceName) && e.SettingName.Equals(settingName)
select e;
ServiceSettingEntity existingSettginEntity = existsQuery.FirstOrDefault();
上述LINQ查询生成以下请求URL:
http://127.0.0.1:10002/devstoreaccount1/PublicSpaceNotificationSettingsTable()?$filter=(ServiceName eq 'PublicSpaceNotification') and (SettingName eq 'expectiss')
该类中的代码生成以下MissingMethodException:
- 我已经看过了表API支持LINQ Queries;
- 看着几个正在使用的计算器解决方案;
- 上TableServiceContext试过IgnoreResourceNotFoundException(的QueryOperators usercomments);
- 打过电话第一或默认(的QueryOperators usercomments)之前与ToList LINQ查询()转换。
,但我不能得到这个工作。
答
确保您有类“ServerSettingEntity”参数的构造函数。继承TableServiceEntity的'DTO'需要一个不带参数的构造函数。
这确实是个问题!谢谢! – Cees