public static List <byte> NumberLiteralToTypeBuffer(string sNum, DbTypeID typeID, List <byte> buffer) { if (DbTypeID.INT == typeID) { Int32 x = Int32.Parse(sNum); if (null == buffer) { buffer = new List <byte>(1 + 4); } buffer.Clear(); buffer.Add(0); Entry.ToBytesAppend((Int32)Entry.ToUInt32(x), buffer); } else if (DbTypeID.LONG == typeID) { Int64 x = Int64.Parse(sNum); if (null == buffer) { buffer = new List <byte>(1 + 8); } buffer.Clear(); buffer.Add(0); Entry.ToBytesAppend64((Int64)Entry.ToUInt64(x), buffer); } else if (DbTypeID.DOUBLE == typeID) { double x = double.Parse(sNum); if (null == buffer) { buffer = new List <byte>(1 + 9); } buffer.Clear(); buffer.Add(0); recordset rs = recordset.Prepare(); rs.PutDouble(x); for (int id = 0; id < 9; id++) { buffer.Add(0); } rs.GetBytes(buffer, 1, 9); } else { // This type isn't comparable with a number! if (null == buffer) { buffer = new List <byte>(1); } buffer.Clear(); buffer.Add(1); // Nullable byte; IsNull=true; } return(buffer); }
public int GetInt32() { rs.GetBytes(dummy, 0, 1); UInt32 u = rs.GetUInt32(); return(Entry.ToInt32(u)); }
// _ReadNextLiteral kept for _ReadNextLiteral static List <byte> _NumberLiteralToType(string sNum, DbColumn ci) { List <byte> buf; if ("int" == ci.Type.Name) { Int32 x = Int32.Parse(sNum); buf = new List <byte>(1 + 4); buf.Add(0); Entry.ToBytesAppend((Int32)Entry.ToUInt32(x), buf); } else if ("long" == ci.Type.Name) { Int64 x = Int64.Parse(sNum); buf = new List <byte>(1 + 8); buf.Add(0); Entry.ToBytesAppend64((Int64)Entry.ToUInt64(x), buf); } else if ("double" == ci.Type.Name) { double x = double.Parse(sNum); buf = new List <byte>(1 + 9); buf.Add(0); recordset rs = recordset.Prepare(); rs.PutDouble(x); for (int id = 0; id < 9; id++) { buf.Add(0); } rs.GetBytes(buf, 1, 9); } else { // This type isn't comparable with a number! buf = new List <byte>(1); buf.Add(1); // Nullable byte; IsNull=true; } return(buf); }