У меня есть таблица хранения таблицы, из которой я хочу получить некоторые данные.Запросы на вставку и обновление работают нормально, но у меня возникают проблемы при попытке выбрать некоторые записи.Ниже приведен код, который я сделал до сих пор:
class TransactionEntity : TableEntity
{
public String s{ get; set; }
public Int32 r { get; set; }
public String e{ get; set; }
public String t{ get; set; }
public String l{ get; set; }
public TransactionEntity(String id, String s, String e, String t)
{
this.r= 0;
this.s= s;
this.RowKey = id;
this.PartitionKey = Guid.NewGuid().ToString();
this.e= e == null ? "" : e;
this.t= t== null ? "" : t;
}
}
Код для управления таблицей:
class TableStorageManager
{
public Boolean AddTransaction(TransactionEntity dto)
{
try
{
// Create the table client.
CloudTableClient tableClient = new CloudTableClient(new System.Uri(ConfigurationManager.AppSettings.Get("TableStorageURI")), new StorageCredentials(ConfigurationManager.AppSettings.Get("TableStorageUser"), ConfigurationManager.AppSettings.Get("TableStoragePassword")));
CloudTable table = tableClient.GetTableReference(ConfigurationManager.AppSettings.Get("TableStorageName"));
table.CreateIfNotExists();
TableOperation op = TableOperation.Insert(dto);
table.Execute(op);
return true;
}
catch (Exception ex)
{
return false;
}
}
public List<TransactionEntity> RetrieveAllFailedTransactions()
{
try
{
CloudTableClient tableClient = new CloudTableClient(new System.Uri(ConfigurationManager.AppSettings.Get("TableStorageURI")), new StorageCredentials(ConfigurationManager.AppSettings.Get("TableStorageUser"), ConfigurationManager.AppSettings.Get("TableStoragePassword")));
CloudTable table = tableClient.GetTableReference(ConfigurationManager.AppSettings.Get("TableStorageName"));
TableQuery<TransactionEntity> query = new TableQuery<TransactionEntity>().Where("s eq '" + ConfigurationManager.AppSettings.Get("E") + "' and r lt " + ConfigurationManager.AppSettings.Get("M") + "");
query.Take(ConfigurationTasks.GetResultLength());
return table.ExecuteQuery(query).ToList();
}
catch (Exception ex)
{
return null;
}
}
public Boolean UpdateTransactionStatus(TransactionEntity dto)
{
try
{
CloudTableClient tableClient = new CloudTableClient(new System.Uri(ConfigurationManager.AppSettings.Get("TableStorageURI")), new StorageCredentials(ConfigurationManager.AppSettings.Get("TableStorageUser"), ConfigurationManager.AppSettings.Get("TableStoragePassword")));
CloudTable table = tableClient.GetTableReference(ConfigurationManager.AppSettings.Get("TableStorageName"));
dto.ETag = "*";
TableOperation op = TableOperation.Replace(dto);
table.Execute(op);
return true;
}
catch (Exception ex)
{
return false;
}
}
}
Также я изменил имена переменных, поэтому извините, если вы, люди, получаете немногопроблемы с чтением их.