ユーザーを Azure テーブルに保存しようとしていますが、ユーザーを作成しようとすると、「オブジェクトがオブジェクトのインスタンスに設定されていません」というメッセージが表示されます。
UserEntity entry = new UserEntity();
entry.UserName = pUserName;
entry.MiniatureImageURL = blob.Uri.ToString();
entry.PhotosUrl.Add(blob.Uri.ToString()); //THIS IS A LIST of strings
Connection cn = new Connection();
cn.AddUserEntries(entry);
私の接続クラスは次のように定義されています。
ここでは、新しいユーザーを現在のコンテキストに追加してから、アイテムをストレージに保存しようとしています:
public void AddUserEntries(UserEntity newItem)
{
try
{
this.context.AddObject("UserEntity", newItem);
this.context.SaveChanges();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
static Connection()
{
try
{
storageAccount = CloudStorageAccount.FromConfigurationSetting("dataconnectionstring");
CloudTableClient.CreateTablesFromModel(
typeof(Connection),
storageAccount.TableEndpoint.AbsoluteUri,
storageAccount.Credentials);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public Connection()
{
try
{
this.context = new UserDataContext(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);
this.context.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
}
catch (Exception ex)
{
throw new Exception("There was a problem trying to create the user. " + ex.Message);
}
}