void BindAll(IntPtr stmt) { int nextIdx = 1; foreach (var b in _bindings) { if (b.Name != null) { b.Index = SQLite3.BindParameterIndex(stmt, b.Name); } else { b.Index = nextIdx++; } } foreach (var b in _bindings) { if (b.Value == null) { SQLite3.BindNull(stmt, b.Index); } else { var bty = b.Value.GetType(); if (b.Value is Byte || b.Value is UInt16 || b.Value is SByte || b.Value is Int16 || b.Value is Int32) { SQLite3.BindInt(stmt, b.Index, Convert.ToInt32(b.Value)); } else if (b.Value is Boolean) { SQLite3.BindInt(stmt, b.Index, Convert.ToBoolean(b.Value) ? 1 : 0); } else if (b.Value is UInt32 || b.Value is Int64) { SQLite3.BindInt64(stmt, b.Index, Convert.ToInt64(b.Value)); } else if (b.Value is Single || b.Value is Double || b.Value is Decimal) { SQLite3.BindDouble(stmt, b.Index, Convert.ToDouble(b.Value)); } else if (b.Value is String) { SQLite3.BindText(stmt, b.Index, b.Value.ToString(), -1, new IntPtr(-1)); } else if (b.Value is DateTime) { SQLite3.BindText(stmt, b.Index, ((DateTime)b.Value).ToString("yyyy-MM-dd HH:mm:ss"), -1, new IntPtr(-1)); } else if (bty.IsEnum) { SQLite3.BindInt(stmt, b.Index, Convert.ToInt32(b.Value)); } } } }
private void BindAll(IntPtr stmt) { int num = 1; foreach (Binding binding in _bindings) { if (binding.Name != null) { binding.Index = SQLite3.BindParameterIndex(stmt, binding.Name); } else { binding.Index = num++; } BindParameter(stmt, binding.Index, binding.Value, _conn.StoreDateTimeAsTicks); } }
void BindAll(Sqlite3Statement stmt) { int nextIdx = 1; foreach (var b in _bindings) { if (b.Name != null) { b.Index = SQLite3.BindParameterIndex(stmt, b.Name); } else { b.Index = nextIdx++; } BindParameter(stmt, b.Index, b.Value, _conn.StoreDateTimeAsTicks); } }