Sebastien Lachance

Learning new things everyday

FluentHibernate - How to Deal With a Reserved Word Column

Suppose you have a class with an Order property. Any sql operation will throw an error because Order is a reserved word. To prevent this from happening, specify the column name yourself and enclose it with back ticks.

public class MessageMap : ClassMap<Message>
{
    public MessageMap()
    {
        Table("messages");
        Id(x => x.Id);
        ...
        Map(x => x.Order, "`Order`");
        ...
    }
}

Comments