RavenDBを使用して私の職場で簡単な概念証明をセットアップしようとしています。デモには現在、基本的なラウンドロビン戦略を実行する2つの断片があります。フェイルオーバーとして、2つの断片をそれぞれ2つ複製します。RavenDBシャーディングにより、アップデートが挿入物として機能するようになります
さまざまなビジネス記録を保存して保存しました。私たちは、マット・ビジネス35、ボブ・ビジネス42など、イドを得るでしょう。しかし、編集すると、既存のレコードは更新されず、挿入されます。そして、ほとんどの場合、オリジナルに加えてmatt-bob-business-42に似たIdを使います。 http://msdn.microsoft.com/en-us/magazine/hh547101.aspx私たちは、しかし、シャーディングのために、DataDocumentstore.csのコードを置き換えることによって、それを変更した
:
var shards = new Dictionary<string, IDocumentStore>
{
{"bob", new DocumentStore() {Url = "http://bob:8080"}},
{"matt", new DocumentStore() {Url = "http://matt:8080"}},
};
var shardStrategy = new ShardStrategy(shards);
instance = new ShardedDocumentStore(shardStrategy);
instance.Conventions.IdentityPartsSeparator = "-";
instance.Initialize();
編集アクションは、以下のように見える:
私たちはガイドとしてこのページに続きますpublic ActionResult Edit(string id)
{
var model = DocumentSession.Load<Business>(id);
return View(model);
}
[HttpPost]
public ActionResult Edit(string id, Business business)
{
try
{
if (ModelState.IsValid)
{
DocumentSession.Store(business);
return RedirectToAction("Index");
}
return View(business);
}
catch
{
return View();
}
}
これらの奇妙な問題を解決するために何かを間違って設定しましたか?それはかなり単純な設定のようですが、更新は常に新しいキー名で挿入します。
私はAutomapperが私のためにオブジェクトを正常にマップすることはできませんでしたが、プロパティを手動でマッピングすることは確実に働いています。 – mandreko