我剛剛開始使用NHibernate(第15次看起來),並且遇到以下問題。NHibernate:映射到DateTime以非標準方式存儲的值的最佳方法
下表:
Table Facility
Column FACILITY_ID integer
Column NAME varchar2(50)
Column MONTH varchar2(5)
無論出於何種原因,一個月是一個字符串而不是本機的日期類型,看起來像這樣:
"200811" represents 11/01/2008
"200307" represents 07/01/2003
you get the idea
我想它映射到以下class
public class Facility {
int Id {get; set;}
string Name {get; set;}
DateTime Month {get; set;}
}
我想將MONTH列映射到Month屬性,但不要退出e知道如何處理這種情況。顯然,我可以有一個受保護的屬性字符串MonthString,並有月份屬性解析該列,但似乎icky。有更好的解決方案嗎?
當您的應用程序是唯一使用數據庫的應用程序時,我會更改數據庫表。 – Paco 2008-12-26 20:19:17