2
我有一个我继承的项目,最近刚刚开始使用RavenDb。我需要将文档保存到一个已连接的数据库中,但我需要将该文档保存到第二个RavenDb。只是想知道我会怎么做呢?以下是我需要改变的方法。将文档从MVC网页保存到第二个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)});
}
非常感谢你,这正是我需要知道的。 – yams