我正在使用Oracle DB,我正在尝试映射这个类:
public 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; } }
使用此映射类:
public class BookMap : ClassMap<Book> { public BookMap() { Id(x => x.Id); Map(x => x.Author); Map(x => x.Title); Map(x => x.Text); } }
但它生成的列类型是NVARCHAR(255),Book.Text属性有超过255个字符.
如何将其映射到可以包含非常大的字符串的类型(例如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"); } }
要么
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) } }