Reputation: 77
trying to retrieve all rows from table storage my code is like this like in the documentation
using Microsoft.Azure.Cosmos.Table;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
public class TableStorage
{
public class MyPoco : TableEntity
{
public string Text { get; set; }
public object PartitionKey { get; internal set; }
public object RowKey { get; internal set; }
}
[FunctionName("TableInput")]
public static void TableInput(
[QueueTrigger("table-items")] string input,
[Table("MyTable")] IQueryable<MyPoco> pocos,
ILogger log)
{
foreach (MyPoco poco in pocos)
{
log.LogInformation($"PK={poco.PartitionKey}, RK={poco.RowKey}, Text={poco.Text}");
}
}
}
the error is : Severity Code Description Project File Line Suppression State Error CS0592 Attribute 'Table' is not valid on this declaration type. It is only valid on 'class' declarations.
What al I missing ?
Upvotes: 0
Views: 418
Reputation: 15551
The TableAttribute
is now resolved from System.ComponentModel.DataAnnotations.Schema
instead of it being resolved from the correct location, which is Microsoft.Azure.WebJobs
. See TableAttribute Class for the faulty attribute.
For this to work, please make sure you have the correct version (4.0.5) installed for NuGet package Microsoft.Azure.WebJobs.Extensions.Storage.
Version 5.0.0 removes the TableAttribute
. I think it will come back in a Cosmos DB package, but haven't gotten around to finding out which one. Yet.
EDIT:
Using a table binding to an IQueryable
is only supported in the Functions v1 runtime. If you are not running on the v1 runtime, you can either bind to an entire CloudTable
, or to one specific item in the table by providing both partition key and row key in the binding.
Also: your POCO properties PartitionKey
and RowKey
hide the ones from TableEntity
. If that's intentional, you might want to make that explicit by adding a new
keyword.
Upvotes: 2