2011-08-18 82 views
1

我想查詢一個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:

enter image description here

  • 我已經看過了表API支持LINQ Queries;
  • 看着幾個正在使用的計算器解決方案;
  • 上TableServiceContext試過IgnoreResourceNotFoundException(的QueryOperators usercomments);
  • 打過電話第一或默認(的QueryOperators usercomments)之前與ToList LINQ查詢()轉換。

,但我不能得到這個工作。

回答

1

確保您有類「ServerSettingEntity」參數的構造函數。繼承TableServiceEntity的'DTO'需要一個不帶參數的構造函數。

+0

這確實是個問題!謝謝! – Cees

相關問題