我在查询Azure表存储时遇到问题-
public List<SubCategoryModel> GetSubCategories()
{
string connStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connStr);
CloudTableClient client = storageAccount.CreateCloudTableClient();
CloudTable table = client.GetTableReference("SubCategories");
List<SubCategoryModel> subCategoryModels = new List<SubCategoryModel>();
TableQuery<SubCategoryEntity> subCategoriesQuery = table.CreateQuery<SubCategoryEntity>();
var query = (from subCategory in subCategoriesQuery
select subCategory).AsTableQuery();
var subCategories = query.Execute();
foreach (SubCategoryEntity entity in subCategories)
{
SubCategoryModel subCategoryModel = new SubCategoryModel();
subCategoryModel.CATEGORYID = entity.CategoryId;
subCategoryModel.DESCRIPTION = entity.Description;
subCategoryModel.SUBCATEGORY = entity.SubCategoryName;
subCategoryModel.SUBCATEGORYID = entity.SubCategoryId;
subCategoryModels.Add(subCategoryModel);
}
return subCategoryModels;
}
web.config:
<add name="ConnString" connectionString="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1"></add>
答案 0 :(得分:0)
糟糕,我的问题...我收到了错误消息,因为我的表名称是SubCategory。 我有用代码编写的SubCategories。
我的坏。固定它。是的!