好用的 GetProperties (參) - Nullable 的處理

摘要:好用的 GetProperties (參) - Nullable 的處理

還記得在 好用的 GetProperties (壹) - Domain Object 中有幾個屬性的型態是 int?、decimal?、Int16?…等 Nullable

因為要Add Parameter時,需指定DbType,其中的轉型,我參考了網路上的寫法:

這時,若傳進去的型別為Nullable時,會有問題

所以,在取得屬性型別透過PropertyType.GetGenericArguments()來取得(感謝MVP阿尼的協助),改寫成: