[NHibernate] NHibernate How to map image fields in SQL Server

Source: Internet
Author: User

Overview

There is a need to manage enterprise intranet information, including icons and links. Consider that the icon is not very large, so the picture is saved directly in the database.

But with NHibernate, how do you map it?

Table 5.5. Large Object Mapping Types

NHibernate Type . NET Type Database Type Remarks
Stringclob System.String Dbtype.string type= "Stringclob" must be specified. Entire field is read into memory.
Binaryblob System.byte[] Dbtype.binary type= "Binaryblob" must be specified. Entire field is read into memory.
Serializable Any System.Object this is marked with SerializableAttribute. Dbtype.binary type= "Serializable" should be specified. The fallback type if no NHibernate type can be found for the property.

Resolved as follows

Hara Hbm.xml

 <  property  name  = "logo"   type  = "byte[]"  >  <  column  name  = "logo"   length  = "2147483647"   Sql-type  Span style= "color: #0000ff;" >= "image"   Not-null  = "false"  Span style= "color: #0000ff;" >/>  </ property  >  

 <  property  name  = "logo"   type  = "Binaryblob"  >  <  column  name  = "logo"   length  = "2147483647"   Sql-type  Span style= "color: #0000ff;" >= "image"   Not-null  = "false"  Span style= "color: #0000ff;" >/>  </ property  >  

Byte[] byte arrays are still used in C # code.

Summarize

Keep track of the problems encountered in the project and record the dots.

[NHibernate] NHibernate How to map image fields in SQL Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.