Fluent NHibernate BinaryBlobType
today i'm working on a MySQL Database, and i don't know how to Map a Byte[] to a BLOB Column...
My Table looks this way:
CREATE TABLE `images` (
`Id` INT NOT NULL AUTO_INCREMENT ,
`imgText` VARCHAR(45) NULL ,
`image` BLOB NULL ,
PRIMARY KEY (`Id`) );
Mapping:
public class imagesMap : ClassMap<images> {
public imagesMap() {
Id(x => x.Id);
Map(x => x.imgText);
Map(x => x.image).CustomType<BinaryBlobType>();
}
}
Buisnessobject:
public class images {
开发者_运维技巧
public virtual int Id{get;set;}
public virtual string imgText{get;set;}
public virtual Byte[] image{get;set;}
}
If i Start my Application i got instantly a Exception:
NHibernate.MappingException: Could not instantiate IType BinaryBlobType: System.MissingMethodException He says for this IType is "No Constructor defined"
I can't unterstand why it is not working, everybody told me i only has to map the CustomType()
I would appreciate each help!
Greetz, Benni
Ok, 10 Minutes later i found the Solution for my Problem by myself.
For everybody who also get stuck with this Problem:
For Mapping a
public virtual byte[] array;
To a BLOB you don't need to Define a custom Type, FNH does even this "automagically".
The Mapping for the Byte-Array should work so:
Map(x=>x.array);
精彩评论