【发布时间】:2017-08-18 16:42:49
【问题描述】:
我有一个继承的项目,我最近才开始使用 RavenDb。我需要将文档保存到一个已经与之建立连接的数据库,但我需要将该文档保存到第二个 RavenDb。只是想知道我会怎么做?以下是我需要更改的方法。
[HttpPost]
public ActionResult SaveContact(ContactInput input)
{
var id = getId();
var profile = RavenSession.Load<TechProfile>(id) ?? new TechProfile();
input.MapPropertiesToInstance(profile);
// check for existing user
if (RavenSession.Query<TechProfile>().Any(x => x.Email == profile.Email && x.Id != profile.Id))
{
return Json(new {error = "Profile already exists with that email address.", msg = "Error"});
}
RavenSession.Store(profile);
return Json(new {error = "", msg = "Success", id = profile.Id.Substring(profile.Id.LastIndexOf("/") + 1)});
}
【问题讨论】:
标签: c# asp.net-mvc ravendb