I'm looking for practical example of storing image into raven database using ravendb attachments. I've just read the http://ravendb.net/docs/client-api/attachments and I have simple question.

If I use poco class should I use property of type byte[] to store image into db, for example

public int id {get; set;}
...
public byte[] image {get; set;}
有帮助吗?

解决方案

No, you most definitely shouldn't. Attachments are a concept separate from your POCOs. You should store the attachment ID as string with your POCOs, if at all. Having a byte[] property in your POCO will bloat the document unnecessarily.

My advice would be to skip attachments and store binaries on the cloud instead - this is also what I wrote in that doc you referred to.

But if you are going to reference an attachment from a POCO, do this using a string reference.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top