开发者

Mapping large string with Fluent NHibernate

开发者 https://www.devze.com 2023-01-04 08:09 出处:网络
I\'m working with an Oracle DB, and I\'m trying to map this class: pu开发者_JAVA技巧blic class Book

I'm working with an Oracle DB, and I'm trying to map this class:

pu开发者_JAVA技巧blic class Book
{
    public virtual int Id { get; private set; }
    public virtual string Author { get; set; }
    public virtual string Title { get; set; }
    public virtual string Text { get; set; }
}

With this mapping class:

public class BookMap : ClassMap<Book>
{
    public BookMap()
    {
        Id(x => x.Id);
        Map(x => x.Author);
        Map(x => x.Title);
        Map(x => x.Text);
    }
}

But the column type that it generates me is NVARCHAR(255), And the Book.Text Property has much more than 255 characters.

How can I map it to a type that can contain a very large string (for example CLOB)?


public class BookMap : ClassMap<Book>
{
    public BookMap()
    {
        Id(x => x.Id);
        Map(x => x.Author);
        Map(x => x.Title);
        Map(x => x.Text).CustomSqlType("CLOB");
    }
}

or

public class BookMap : ClassMap<Book>
{
    public BookMap()
    {
        Id(x => x.Id);
        Map(x => x.Author);
        Map(x => x.Title);
        Map(x => x.Text).Length(500);  // nvarchar(500)
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消