1
votes

I want to store pdf file inside sql server 2008R2. ORM is nhibernate so my property is

public virtual byte[] PDFFile { get; set; }       

and it is mapped like

Property(x => x.PDFFile);  

inside database column is of type varbinary(MAX)

I think problem resides in the mapping of this property but I dont know how to overcome this.

On upload I'm getting

The length of the byte[] value exceeds the length configured in the mapping/parameter.

1

1 Answers

1
votes

It is caused by nHibernate limiting the length of that column type to 8000.

You can get round this by changing your fluent mapping to this:

Map(x => x.PDFFile).CustomType("BinaryBlob").Length(100000);

Where you can set the length to be whatever works for you although typically it should be int.MaxValue or less.