public static byte[] GetBytes(DateTime?dtVal) { if (dtVal.HasValue) { List <byte> arrRet = new List <byte> { NOTNULL }; arrRet.AddRange(BitConverterExtension.GetBytes((DateTime)dtVal)); return(arrRet.ToArray()); } else { List <byte> arrRet = new List <byte> { ISNULL }; arrRet.AddRange(BitConverterExtension.GetBytes(DateTime.UtcNow)); return(arrRet.ToArray()); } }
public static byte[] GetBytes(decimal?decVal) { if (decVal.HasValue) { List <byte> arrRet = new List <byte> { NOTNULL }; arrRet.AddRange(BitConverterExtension.GetBytes((decimal)decVal)); return(arrRet.ToArray()); } else { List <byte> arrRet = new List <byte> { ISNULL }; arrRet.AddRange(BitConverterExtension.GetBytes((decimal)0)); return(arrRet.ToArray()); } }
public static DateTime?ToNDateTime(byte[] arrBytes, int intOffset = 0) { return(arrBytes[intOffset++] == ISNULL ? (DateTime?)null : BitConverterExtension.ToDateTime(arrBytes, intOffset)); }
public static decimal?ToNDecimal(byte[] arrBytes, int intOffset = 0) { return(arrBytes[intOffset++] == ISNULL ? (decimal?)null : BitConverterExtension.ToDecimal(arrBytes, intOffset)); }