RavenDb学习(十)附件,存储大对象

时间:2022-04-29
本文章向大家介绍RavenDb学习(十)附件,存储大对象,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1、读取

Raven.Abstractions.Data.Attachment attachment = documentStore.DatabaseCommands.GetAttachment("videos/1");

2、存储、更新

Stream data = new MemoryStream(new byte[] { 1, 2, 3 }); // don't forget to load the data from a file or something!
documentStore.DatabaseCommands.PutAttachment("videos/2", null, data,
                                             new RavenJObject {{"Description", "Kids play in the garden"}});

3、删除附件

documentStore.DatabaseCommands.DeleteAttachment("videos/1", null);

4、读取元数据

Raven.Abstractions.Data.Attachment attachmentMetadata = documentStore.DatabaseCommands.HeadAttachment("Description");

5、更新元数据

documentStore.DatabaseCommands.UpdateAttachmentMetadata("videos/1", null, new RavenJObject
                                                                              {
                                                                                  { "Description", "Kids play in the bathroom" }
                                                                              });