The basic mapping relationship is as follows :

NHibernate type

.NET type

Database type

remarks

AnsiChar

System.Char

DbType.AnsiStringFixedLength - 1 char

Boolean

System.Boolean

DbType.Boolean

When no type is specified (type)  Property .

Byte

System.Byte

DbType.Byte

When no type is specified (type)  Property .

Char

System.Char

DbType.StringFixedLength - 1 char

When no type is specified (type)  Property .

DateTime

System.DateTime

DbType.DateTime - ignores the milliseconds

When no type is specified (type)  Property .

Decimal

System.Decimal

DbType.Decimal

When no type is specified (type)  Property .

Double

System.Double

DbType.Double

When no type is specified (type)  Property .

Guid

System.Guid

DbType.Guid

When no type is specified (type)  Property .

Int16

System.Int16

DbType.Int16

When no type is specified (type)  Property .

Int32

System.Int32

DbType.Int32

When no type is specified (type)  Property .

Int64

System.Int64

DbType.Int64

When no type is specified (type)  Property .

PersistentEnum

System.Enum

Potential types correspond to DbType

Do not specify... In the mapping file type="PersistentEnum". Instead, provide the full assembly name of the enumeration ,  Give Way NHibernate Use reflection to guess type . The underlying types used by enumeration determine the appropriate DbType..

Single

System.Single

DbType.Single

When no type is specified (type)  Property .

Ticks

System.DateTime

DbType.Int64

type="Ticks" Must be specified .

TimeSpan

System.TimeSpan

DbType.Int64

When no type is specified (type)  Property .

Timestamp

System.DateTime

DbType.DateTime -  Depending on the database support

type="Timestamp" Must be specified .

TrueFalse

System.Boolean

DbType.AnsiStringFixedLength - A character ,'Y'  perhaps 'N'

type="TrueFalse" Must be specified .

YesNo

System.Boolean

DbType.AnsiStringFixedLength - A character ,'Y'  perhaps 'N'

type="YesNo" Must be specified .

2. Apply type mapping

NHibernate Type

.NET Type

Database Type

Remarks

AnsiString

System.String

DbType.AnsiString

type="AnsiString" Must be specified .

CultureInfo

System.Globalization.CultureInfo

DbType.String - Show culture (culture) Of 5 Characters

When no type is specified (type)  Property .

Binary

System.Byte[]

DbType.Binary

When no type is specified (type)  Property .

Type

System.Type

DbType.String Save application set permission naming .

When no type is specified (type)  Property .

String

System.String

DbType.String

When no type is specified (type)  Property .

3. Binary type mapping

Hibernate Type

.NET Type

Database Type

Remarks

StringClob

System.String

DbType.String

type="StringClob" Must be specified . The entire field is readable in memory .

BinaryBlob

System.Byte[]

DbType.Binary

type="BinaryBlob" Must be specified . The entire field is readable in memory .

Serializable

Any System.Object  Serializable tags must be marked

DbType.Binary

type="Serializable"  Should be designated .  If you can't find NHibernate type , This is the last type to rely on .

From the original :http://www.cnblogs.com/GoodHelper/archive/2011/02/24/nhibernate06.html

NHibernate More articles on mapping relationships

  1. Nhibernate The mapping relationship , One to many The reflection of many to one and many opponents in the mapping file .

    I made the first one today Nhibernate project , Feel the stone to cross the river , Learned something , Here, I will summarize some of the mapping relations I have learned , Share with you , As a beginner , If there is something wrong, I hope you can point it out . First of all, I'd like to explain a few pieces to be established ...

  2. MyGeneration The template to generate NHibernate Mapping files and relationships (one-to-one,one-to-many,many-to-many)

    MyGeneration Several NHibernate Templates are already powerful , But there are still some problems . for example :Guid Poor primary key support , The code is not easy to modify , Chinese comments are not supported . So I decided to rewrite this template myself . I've extracted some general functions ...

  3. use MyGeneration The template to generate NHibernate Mapping files and relationships

    Use my MyGeneration The template to generate NHibernate Mapping files and relationships (one-to-one,one-to-many,many-to-many) MyGeneration Several NHibernate model ...

  4. NHibernate Mapping Foundation ( Third articles ) Simple mapping 、 Combined the primary key

    NHibernate Mapping Foundation ( Third articles ) Simple mapping . Combined the primary key NHibernate Rely entirely on the configuration file to get all the information it needs , Where the mapping file , It gets the database and C# All sources of information about procedural relationships . One . Simple mapping Let's start with ...

  5. ASP.NET Core The routing [1]: register URL Patterns and HttpHandler The mapping relation of

    ASP.NET Core The route is through a type of RouterMiddleware It's implemented by middleware . If we're going to deal with it in the end HTTP The requested component is called HttpHandler, that RouterMiddleware middle ...

  6. Hibernate4.2.4 introduction ( Two )—— One to many mapping

    One . Preface We've learned before hibernate The basis of , Learn to add, delete, modify and check simple operations , However, we have in our database 1 For more than , How to 1, many-to-many ,hibernate It's based on ORM Open source framework based on , So that we don't have to write S ...

  7. EF The inheritance mapping relation in TPH、TPT and TPC And some specific examples

    This chapter explains EF The inheritance mapping relation in , It is divided into TPH.TPT.TPC. Specifically : 1.TPH:Table Per Hierarchy This is a EF The default inheritance mapping of : A table holds all the columns of the base class and subclass , Automatically generated discr ...

  8. hibernate note -- Using annotations (annotation) Mode configuration list ( double ) Mapping to many to one

    The previous articles all introduced how to use configuration files to map entity classes to database tables , This way is more troublesome , every last pojo Class needs to write a corresponding *.hbm.xml, There's no doubt a lot more code , But it also has the advantage of easy maintenance , To facilitate development ,Hi ...

  9. hibernate note -- single ( double ) Many to many mapping to

    In the case of one-way many to many mapping relationship , Let's assume we have two tables , A list of roles Role, A list of permissions Function, We know a role or a user , There may be multiple operation permissions , And an operation permission is owned by multiple users at the same time , If I ...

Random recommendation

  1. mysql - Other

    1.mysql View table fields and field descriptions SELECT column_name, column_comment FROM information_schema.columns WHERE table_sch ...

  2. Python Binding method , Unbound method , Class method , Example method , Static methods

    >>> class foo(): clssvar=[1,2] def __init__(self): self.instance=[1,2,3] def hehe(self): pr ...

  3. About PHP Array to string

    With the development of the times , Our development technology is also updated , about PHP It's more common , So I studied PHP Array to string , Let's share it with you , I hope you found that useful . Need to be used frequently PHP Processing characters string,PHP built-in ...

  4. SxsTrace Tool usage

    Windows7 There is a powerful SxsTrace Tools , It can track the version number and path of the dynamic library needed for debugging application execution . SxsTrace Method used : 1. First of all, it has to be Administrator Login as user , open ...

  5. 【Git】 stay GitHub or OSChina After you build a new project , How to do it locally for the first time push Code to server

    scene 1: Put the local code push To the remote warehouse master The main branch # initialization git, perform init After the command , New local branch is created by default master git init # Associated remote warehouse git remote add origi ...

  6. wpf-x- Command elements

    1. x:Code For code prepositions   Maybe C# The code is embedded in the front end 2. x:XData For embedding xml file

  7. C# Read ini file , I can't read the reason

    First, assign the relevant read ini File code public class INIHelper { public string inipath; [DllImport("kernel32")] pri ...

  8. C# List Deep replication ( turn )

    C# List Deep replication 1. About deep and shallow copies C# Two types are supported : Value type and reference type Value type (Value Type): Such as char, int, float, Enumeration types and structure types Reference type (Referenc ...

  9. luogu P3941 Entering the battle

    Toot toot I think this problem is very similar to the biggest submatrix problem , All are O(n4) Two dimensional prefixes and violence are nice to think about ,O(n3) A positive solution requires a point transformation . O(n4) Let's not talk about violence , Two dimensional prefixes and , Enumerate all rectangles , We should be able to get 55 branch . O(n3) We need dimension reduction ...

  10. hibernate—— The first simple use

    In advance jdk.mysql.hibernate must jar package .mysql Connect jar package mysql In the table Java Medium bean,User class package com.xiaostudy.demo; publi ...