Azure テーブル ストレージにクエリを実行しようとしています。そのために、次の2つの方法を使用します。
テーブル サービス コンテキスト:
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 クエリを見てきました。
- いくつかの動作中のスタックオーバーフロー ソリューションを調べました。
- TableServiceContext ( QueryOperators のユーザーコメント) で IgnoreResourceNotFoundException を試しました。
- 最初またはデフォルト ( QueryOperators のユーザーコメント)を呼び出す前に、ToList() を使用して linq クエリを変換しようとしました。
しかし、私はこれを機能させることができません。