I am trying to use Filestream in sql server 2008 to store user uploaded images.
My problem is that NHibernate will not be an error, but it will also not save data in the database. A record is not created.
Below is the image class - this is a non-standard class (not to be confused with System.Drawing.Image)
public class ImageMap : ClassMap<Image>
{
public ImageMap()
{
WithTable("Images");
Id(x => x.ImageId).GeneratedBy.GuidComb().WithUnsavedValue(Guid.Empty);
Map(x => x.ImageData);
Map(x => x.Extension);
References(x => x.Owner, "UserId");
}
}
My save method is as follows:
public void Save(Image image)
{
ISession session = GetSession();
session.SaveOrUpdate(image);
}
Maybe I'm wrong, maybe my mapping is disabled. ImageData is the varbinary (max) field in the database.
source
share