的默认值(当前日期) code>在sqlServer 2008中使用映射类?how can I set default value (current date) for SubmutionDate in the sqlServer 2008 using mapping class?我这样做,但它不起作用并引发sqlDateTimeException!I did like this but it doesn't work and raise an sqlDateTimeException! Map(x => x.SubmitionDate).Default(System.DateTime.Now.ToString()).Not.Nullable();推荐答案仅当您的会话工厂被创建。因此,您不能直接在映射中指定日期。The mapping is being processed only when your session factory is being created. Therefore you can't specify the date directly in mapping.然而,您可以指定SQL(或更改为HQL)函数,如下所示:You can however specify the SQL (or rather HQL) function instead like this:Map(x => x.SubmitionDate).Default("getdate()").Not.Nullable(); 这篇关于指定FluenNhibernate映射类中Datetime属性的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 10:34