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

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

问题描述

如何让 nhibernate 流畅地在使用 varbinary(max) 字段大小的 sql server 2005 表中创建 varbinary 字段?目前我总是得到默认值 varbinary(8000),它不够大,因为我将要存储图像文件.

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.

我已经尝试使用 CAstle.ActiveRecord,但还没有取得任何成功.

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

推荐答案

我不确定为什么您的 ActiveRecord 示例不起作用,但您可以尝试设置列的长度.

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

使用 Fluent NHibernate,您应该可以做到

With Fluent NHibernate, you should be able to do

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

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

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