I am attempting to use Filestream in sql server 2008 to store user uploaded images.
My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created.
The Image class below is a custom 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 method to save looks like this:
public void Save(Image image)
{
ISession session = GetSession();
session.SaveOrUpdate(image);
}
Maybe I'm saving wrong, maybe my mapping is off. ImageData is a varbinary(max) field in the database.