/// <summary> /// 取得欄位值後轉型成DateTime。 /// </summary> /// <param name="row">資料列。</param> /// <param name="fieldName">欄位名稱。</param> /// <param name="dataRowVersion">資料列版本。</param> public static DateTime ValueAsDateTime(this DataRow row, string fieldName, DataRowVersion dataRowVersion) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CDateTime(row[fieldName, dataRowVersion])); } return(default(DateTime)); }
/// <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> /// 取得欄位值後轉型成string。 /// </summary> /// <param name="row">資料列。</param> /// <param name="fieldName">欄位名稱。</param> /// <param name="dataRowVersion">資料列版本。</param> public static string ValueAsString(this DataRow row, string fieldName, DataRowVersion dataRowVersion) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CStr(row[fieldName, dataRowVersion])); } return(""); }
/// <summary> /// 取得欄位值後轉型成bool。 /// </summary> /// <param name="row">資料列。</param> /// <param name="fieldName">欄位名稱。</param> /// <param name="dataRowVersion">資料列版本。</param> public static bool ValueAsBool(this DataRow row, string fieldName, DataRowVersion dataRowVersion) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CBool(row[fieldName, dataRowVersion])); } return(false); }
/// <summary> /// 取得欄位值後轉型成decimal。 /// </summary> /// <param name="row">資料列。</param> /// <param name="fieldName">欄位名稱。</param> /// <param name="dataRowVersion">資料列版本。</param> public static decimal ValueAsDecimal(this DataRow row, string fieldName, DataRowVersion dataRowVersion) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CDecimal(row[fieldName, dataRowVersion])); } return(0); }
/// <summary> /// 取得欄位值後轉型成float /// </summary> /// <param name="row">資料列</param> /// <param name="fieldName">欄位名稱</param> /// <returns></returns> public static float ValueAsFloat(this DataRow row, string fieldName) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CFloat(row[fieldName])); } return(0); }
/// <summary> /// 取得欄位值後轉型成double /// </summary> /// <param name="row">資料列</param> /// <param name="fieldName">欄位名稱</param> /// <returns></returns> public static double ValueAsDouble(this DataRow row, string fieldName) { if (BaseFunc.IsNotNull(row) && DataFunc.HasField(row, fieldName)) { return(BaseFunc.CDouble(row[fieldName])); } return(0); }
/// <summary> /// 取得XElement > XElement的值 /// </summary> /// <param name="elem"></param> /// <param name="elemName"></param> /// <returns></returns> public static string ElementValue(this XElement elem, XName elemName) { if (BaseFunc.IsNotNull(elem.Element(elemName))) { return(elem.Element(elemName).Value); } else { return(""); } }
/// <summary> /// 判斷二個欄位值是否相同。 /// </summary> /// <param name="value1">第一個欄位值。</param> /// <param name="value2">第二個欄位值。</param> public static bool FieldValueIsEquals(object value1, object value2) { if (BaseFunc.IsNotNull(value1) && BaseFunc.IsNotNull(value1)) { if (!BaseFunc.IsDBNull(value1) && !BaseFunc.IsDBNull(value2)) { return(value1.Equals(value2)); } else if (BaseFunc.IsDBNull(value1) && BaseFunc.IsDBNull(value2)) { return(true); } else { return(false); } } return(false); }