更新 RavenDB 中的文档
我正在使用 asp.net MVC2。
我有一个模型定义为
public class Department
{
[ScaffoldColumn(false)]
public object Id { get; set; }
[Required(ErrorMessage = "Department Name is required")]
[StringLength(25)]
[DisplayName("Department Name")]
public string Name { get; set; }
[DefaultValue(true)]
[DisplayName("Active?")]
public bool Active { get; set; }
}
如何通过我的控制器更新现有的部门文档? 我的编辑操作定义为
[HttpPost]
public ActionResult Edit(string id, Department department)
{
..
}
此处所述的答案告诉有一个PATCH
更新文档的命令。 但我在 Raven 客户端 API 的 IDocumentSession
类中没有找到这个,
我不想先获取文档,然后像 RavenDB 的 MVCMusicStore 示例中那样更新它
var albumModel = session.Load<Album>(id);
//Save Album
UpdateModel(albumModel, "Album");
session.SaveChanges();
I am using asp.net MVC2.
I have a model defined as
public class Department
{
[ScaffoldColumn(false)]
public object Id { get; set; }
[Required(ErrorMessage = "Department Name is required")]
[StringLength(25)]
[DisplayName("Department Name")]
public string Name { get; set; }
[DefaultValue(true)]
[DisplayName("Active?")]
public bool Active { get; set; }
}
How to update an existing department document through my controller?
my edit action is defined as
[HttpPost]
public ActionResult Edit(string id, Department department)
{
..
}
answer stated here tells there is a PATCH
command to update a document.
But i didn't find this in IDocumentSession
class in Raven's Client API
I do not want to first get the document and then update it like the way it is done in RavenDB's MVCMusicStore example
var albumModel = session.Load<Album>(id);
//Save Album
UpdateModel(albumModel, "Album");
session.SaveChanges();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用如下代码:
请参阅此帖子讨论组了解更多信息
You need to use code like this:
See this thread on the discussion group for more info