public object SelectScalar(String query, params object[] arguments) { using (var cmd = new SqliteCommand()) { cmd.Connection = ActiveConnection; cmd.CommandText = query; var n = 1; foreach (object p in arguments) { cmd.Parameters.AddWithValue(String.Format("@p{0}", n), p); n++; } object result = cmd.ExecuteScalar(); if (result == DBNull.Value || result == null) { return(null); } if (DbRef.CheckIsRef(result.ToString())) { return(DbRef.FromString(result.ToString())); } return(result); } }
public IDbRef CreateDbRef(string str) { if (DbRef.CheckIsRef(str)) { return(DbRef.FromString(str)); } throw new Exception("Cannot parse Dbref " + str); }
public static object DbValue(this object v) { if (v != null) { var s = v as string; if (s != null && DbRef.CheckIsRef(s)) { return(DbRef.FromString(s)); } if (v == DBNull.Value) { return(null); } } return(v); }
public object SelectScalar(string query, params object[] arguments) { return(Exec(query, cmd => { var n = 1; foreach (object p in arguments) { cmd.Parameters.AddWithValue(string.Format("@p{0}", n), p); n++; } object result = cmd.ExecuteScalar(); if (result == DBNull.Value || result == null) { return null; } if (DbRef.CheckIsRef(result.ToString())) { return DbRef.FromString(result.ToString()); } return result; })); }