/// <summary> /// 取得欄位值後轉型成Guid。 /// </summary> /// <param name="row">資料列。</param> /// <param name="fieldName">欄位名稱。</param> /// <param name="dataRowVersion">資料列版本。</param> public static Guid ValueAsGuid(this DataRow row, string fieldName, DataRowVersion dataRowVersion) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CGuid(row[fieldName, dataRowVersion])); } return(Guid.Empty); }
/// <summary> /// 將傳入值轉型為指定欄位資料型別。 /// </summary> /// <param name="fieldDbType">欄位資料型別。</param> /// <param name="value">傳入值。</param> public static object CFieldValue(EFieldDbType fieldDbType, object value) { switch (fieldDbType) { case EFieldDbType.String: return(BaseFunc.CStr(value).Trim()); // 去除左右空白 case EFieldDbType.Text: return(BaseFunc.CStr(value).Trim()); // 去除左右空白 case EFieldDbType.Boolean: return(BaseFunc.CBool(value)); case EFieldDbType.Integer: return(BaseFunc.CInt(value)); case EFieldDbType.Double: return(BaseFunc.CDouble(value)); case EFieldDbType.Currency: return(BaseFunc.CDecimal(value)); case EFieldDbType.DateTime: if (BaseFunc.IsDBNull(value)) { return(value); } else { return(BaseFunc.CDateTime(value)); } case EFieldDbType.GUID: return(BaseFunc.CGuid(value)); default: return(value); } }
/// <summary> /// 取得指定名稱的參數值,並轉型為 Guid 值。 /// </summary> /// <param name="name">參數名稱。</param> public Guid GetParameterAsGuid(string name) { return(BaseFunc.CGuid(GetParameterValue(name, Guid.Empty))); }