2
It is possible to serialize and write file in database with Nhibernate?
public virtual File Arquivo { get; set; }
He does not let map and did not want to record without using Nhibernate to follow the pattern
2
It is possible to serialize and write file in database with Nhibernate?
public virtual File Arquivo { get; set; }
He does not let map and did not want to record without using Nhibernate to follow the pattern
4
Yes, it is possible. In C# the type has to be byte[]
and not File
.
Not least because File
is a static class, you will never be able to use an instance of File
.
In the mapping would be:
Property(x => x.Arquivo, map =>
{
map.Type(NHibernateUtil.BinaryBlob);
map.Length(Int32.MaxValue);
});
Thanks for the help, I used as follows: public virtual byte[] Arquivo { get; set; }
byte[] FileSream = File.ReadAllBytes(txtArquivo.Text);
 Objeto.Arquivo = FileSream;
apparently recorded normally, now I’m searching how to return this information and write the file in a directory.
From what you’re saying, it seems to be the case mark an answer as accepted. Here we do not write "solved" in the question. If you have an answer that really helped you, mark it as accepted. If you came to the solution on your own, put in the solution as an answer. So content is more organized and easier to find in the future by other people with similar problems.
Browser other questions tagged c# nhibernate
You are not signed in. Login or sign up in order to post.
It is possible. How do you map the classes?
– Jéf Bueno
Check out this post: http://stackoverflow.com/a/26686392/2588695
– JcSaint
If it is similar to Entityframework, you should map a byte[] property to the field in the database that represents this file (varbinary for example).
– Vinícius