Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public IDbRef CreateDbRef(string str)
 {
     if (DbRef.CheckIsRef(str))
     {
         return(DbRef.FromString(str));
     }
     throw new Exception("Cannot parse Dbref " + str);
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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;
            }));
        }