I am retrieving data from Azure Table Storage and storing them in IEnumerable, but I don't know how to convert this IEnumerable<T>
into IReliableDictionary<string, Store>
, so that I can save this store data into state manager of stateful service.
var storesRepo = await StateManager.GetOrAddAsync<IReliableDictionary<long, Store>>("");
So how can I insert this IEnumerable<Store>
into storesRepo
?
Store Class:
public class Store : TableEntity
{
public string Name { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
public string Address { get; set; }
public double Distance { get; set; }
public string Email { get; set; }
public string City { get; set; }
}
ReliableDictionary<string, Store>
where key is store name.
var storesRepo = await StateManager.GetOrAddAsync<IReliableDictionary<string, Store>>("someName");
IEnumerable<Store> stores = await GetFromTableStorage();
using (ITransaction tx = base.StateManager.CreateTransaction())
{
foreach(var store in stores)
{
await storesRepo.AddAsync(tx, store.Name, store, cancellationToken);
}
await tx.CommitAsync();
}