views:

77

answers:

2

I'm using nhibernate as my ORM and Firebird embedded as the database. How would I got about saving a DateTime to the database?

This is an example definition of a class.

[Class(Table = "table")]
public class Table
{
    private int mId;
    private DateTime mDate;

    [Id(Name = "Id"),Generator(1, Class = "native")]
    public virtual long Id
    {
      get { return mId; }
      set { mId = value; }
    }

    [Property]
    public virtual DateTime Date
    {
      get { return mDate; }
      set { mDate = value; }
    }
}

I'm guessing that I have to specify something in the Property attribute but I don't know what.

When trying this mapping I get the follwoing error:

FirebirdSql.Data.FirebirdClient.FbException: Dynamic SQL Error SQL error code = -104 Token unknown - line 1, char 63 Date

A: 

I firmly believe that NHibernate will figure that out himself.

At least, when using xml files to specify the mapping, you're not obliged to define the type since NHibernate can figure it out by himself, so I think that NHibernate will manage to do that in your situation as well.

Frederik Gheysels
I guess I should have been clearer to say that my current implementation does not work.
Robert Höglund
+1  A: 

Just a guess, but could it be related to the property name being a reserved word (Date)?

Douglas Tosi
Very good, thank you.
Robert Höglund