4

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

1 Answer 1

5

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.