小编mob*_*ill的帖子

Fluent NHibernate mapping to a SQL Server CHAR(10) ID column

New to both NHibernate and Fluent NHibernate and I'm trying to resolve a performance problem in some inherited code caused by a conversion of a CHAR(10) column to NVARCHAR.

From SQL Profiler:

exec sp_executesql N'select mytestclas0_.LinkId as LinkId45_, 
   mytestclas0_.Href as Href45_, 
   mytestclas0_.LinkActive as LinkActive45_ 
from MessageLinks mytestclas0_ 
where mytestclas0_.LinkId=@p0',N'@p0 nvarchar(4000)',@p0=N'BzE2T48HMF'
Run Code Online (Sandbox Code Playgroud)

您可以看到来自NHibernate的ID被转换为NVARCHAR.

表定义:

CREATE TABLE [dbo].[MyTable](
    [ID] [int] NULL,
    [Href] [nvarchar](1000) NULL,
    [LinkActive] [bit] NOT NULL,
    [LinkId] [char](10) NOT NULL
 )
Run Code Online (Sandbox Code Playgroud)

类文件:

public class MyTestClass {
    public MyTestClass() …
Run Code Online (Sandbox Code Playgroud)

c# sql sql-server nhibernate fluent-nhibernate

4
推荐指数
2
解决办法
2246
查看次数

标签 统计

c# ×1

fluent-nhibernate ×1

nhibernate ×1

sql ×1

sql-server ×1