如何获得流利的nhibernate在sql server中创建一个varbinary(max)字段 [英] How do I get fluent nhibernate to create a varbinary(max) field in sql server

查看:143
本文介绍了如何获得流利的nhibernate在sql server中创建一个varbinary(max)字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到流利的nhibernate在SQL Server 2005表中使用varbinary(max)的字段大小创建一个varbinary字段?目前我总是得到一个varbinary(8000)的默认值,这个值不够大,因为我将要存储图像文件。



我试过使用CAstle.ActiveRecord,但还没有任何成功。

  [ActiveRecord] 
公共类MyFile:实体
{
公共虚拟字符串FileName {get;组; }
公共虚拟字符串FileType {get;组; }
public virtual int FileVersion {get;组; }
public virtual int FileLength {get;组; }








$ b $ {组; }
}

现在找不到解决方案, / p>

czk

解决方案

我不确定您的ActiveRecord示例不工作,但你可以尝试设置列的长度。



使用流利的NHibernate,你应该可以做

  Map(x => x.FileData)
.WithLengthOf(2147483647)


How can I get fluent nhibernate to create a varbinary field in a sql server 2005 table that uses a field size of varbinary(max)? At the moment I always get a default of varbinary(8000), which isn't big enough as i'm going to be storing image files.

I've tried using CAstle.ActiveRecord but havent had any success yet.

 [ActiveRecord]
 public class MyFile : Entity
{
    public virtual string FileName { get; set; }
    public virtual string FileType { get; set; }
    public virtual int FileVersion { get; set; }
    public virtual int FileLength { get; set; }

    [Property(ColumnType = "BinaryBlob", SqlType = "VARBINARY(MAX)")]
    public virtual byte[] FileData { get; set; }   
}

Been failing at finding a solution for hours now, so thanks in advance

czk

解决方案

I'm not sure why your ActiveRecord example is not working, but there you might try setting the length of the column.

With Fluent NHibernate, you should be able to do

Map(x => x.FileData)
    .WithLengthOf(2147483647)

这篇关于如何获得流利的nhibernate在sql server中创建一个varbinary(max)字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆