Question

I am trying to query a Azure Table Storage. For that I use the following two methods:

TableServiceContext:

public IQueryable<T> QueryEntities<T>(string tableName) where T : TableServiceEntity
{
    this.ResolveType = (unused) => typeof(T);
    return this.CreateQuery<T>(tableName);
}

Code that uses the method above:

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();

The LINQ query above generates the following request url:

http://127.0.0.1:10002/devstoreaccount1/PublicSpaceNotificationSettingsTable()?$filter=(ServiceName eq 'PublicSpaceNotification') and (SettingName eq 'expectiss')

The code in the class generates the following MissingMethodException:

enter image description here

  • I have looked at the supported LINQ Queries for the Table API;
  • Looked at several working stackoverflow solutions;
  • Tried IgnoreResourceNotFoundException on the TableServiceContext (usercomments of QueryOperators);
  • Tried to convert the linq query with ToList() before calling first or default (usercomments of QueryOperators).

but I can't get this to work.

Was it helpful?

Solution

Make sure you have parameterless constructor for the class "ServerSettingEntity". The ‘DTO’ that inherits TableServiceEntity needs a constructor with no parameters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top