我不断收到此错误,“当前值'String.Empty'类型与期望的'System.Boolean'类型不兼容,当我尝试循环来自Azure表的一大堆实体,我只是使用Azure的新手,所以这可能非常容易,我得到的错误。尝试通过Azure表中的实体循环时出错
我的代码:
private void registerButton_Click(object sender, RoutedEventArgs e)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
// Create the table client
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Get the data service context
TableServiceContext serviceContext = tableClient.GetDataServiceContext();
// Create a new customer entity
user = new UserDetailsEntity();
//Setting the fields of the new userEntity
user.username = usernameText.Text;
user.password = passwordText.Text;
user.subscriptionID = subText.Text;
user.subscriptionName = subscriptionNameText.Text;
user.thumbprint = thumbprintText.Text;
user.email = emailText.Text;
user.phoneNumber = "3530" + numberText.Text;
int rowCount = 1;
CloudTableQuery<UserDetailsEntity> Query = (from en in serviceContext.CreateQuery<UserDetailsEntity>("userdetails")
select en).AsTableServiceQuery<UserDetailsEntity>();
//error occurs in the next line
foreach (UserDetailsEntity ent in Query)
{
rowCount++;
}
user.RowKey = rowCount.ToString();
// Add the new customer to the people table
serviceContext.AddObject("userdetails", user);
// Submit the operation to the table service
serviceContext.SaveChangesWithRetries();
//Set the variables so they can be retrieved when the next screen loads
Application.Current.Properties["username"] = usernameText.Text;
Application.Current.Properties["password"] = passwordText.Text;
Window1 userHome = new Window1();
this.Close(); //to close Password window
userHome.Show(); //to show Main form
}
干杯的答复,错误是发生上线 的foreach(在查询UserDetailsEntity ENT) 这就是为什么我很困惑,为什么错误是发生 – StevenR 2012-03-30 13:32:41
@StevenR对不起,我错过了,我有更新了我的答案,以帮助你更好地理解这一点 – 2012-03-30 13:47:37
非常感谢,我会尽力做你的建议 – StevenR 2012-03-30 14:27:40