I’ve read various things but I didn’t see something specific, so I’m reposting. Sorry if I missed one and duplicate posted.
I am storing files in a database; previously, with ADO.NET Entity Framework, I would use image type and it streams it as byte[] array.
Is that the approach to do it in NHibernate with FluentNHibernate mappings? I setup the column as image. I defined this as the mapping for the property (which the C# property is a byte[] array):
Map(i => i.FileContents).CustomSqlType("image");
Is that the correct way to set this up? I am getting an error and am not sure if its related to this?
Thanks.
You can also map
Custom<TType>s toNHibernate.TypetypesFor instance:
I’ve mapped files stored as binary, but they weren’t the ‘image’ type.
I did a quick google search and found a post with an ImageUserType which you could try to specify instead.
http://weblogs.asp.net/ricardoperes/archive/2009/09/17/nhibernate-image-user-type.aspx
edit. This user type looks a lot better: http://www.martinwilley.com/net/code/nhibernate/usertype.html