Esempio n. 1
0
        public bool Disconnect()
        {
            bool succeeded = true;

            /* disconnects a manifold */
            if (secondarydbs != null)
            {
                foreach (Iddl db in secondarydbs)
                {
                    if (!db.Disconnect())
                    {
                        succeeded = false;
                    }
                }
            }
            if (primarydb != null) /* inserted [dlatikay 20120420] when no connection could be made, this will be null */
            {
                if (!primarydb.Disconnect())
                {
                    succeeded = false;
                }
            }
            /* complete */
            Tracing.InfoDAL("Disconnected from a manifold of {0}.", Count.ToString());
            return(succeeded);
        }
Esempio n. 2
0
        public virtual bool Compile(Isqlcompiler _parent)
        {
            parent = _parent;

            /* 1. special case with toplevel select statement: if there is an ordering defined in the field list,
             * then we append those ordering hints to the order by clause even if there is none */
            if (stmt is selectstatement && (!(stmt is unionstatement)))
            {
                selectstatement s = stmt as selectstatement;
                foreach (selectfield f in s.Fields)
                {
                    if (f.definesOrder)
                    {
                        if (parent != null && parent.TypeOfCommand.Equals(typeof(insertstatement)) == false)
                        {
                            throw new ArgumentException("subquery may not define a sort order");
                        }
                        if (s.OrderBy == null)
                        {
                            s.OrderBy = new orderbystatement();
                        }
                        s.OrderBy.fields.Add(f);
                    }
                }
#if DEBUG
                if (s.Where != null && s.Where.expressions.Count <= 0)
                {
                    throw new ArgumentException("cannot have empty 'where' clause");
                }
                if (s.Having != null && s.Having.expressions.Count <= 0)
                {
                    throw new ArgumentException("cannot have empty 'having' clause");
                }
                if (s.GroupBy != null && s.GroupBy.fields.Count <= 0)
                {
                    throw new ArgumentException("cannot have empty 'group by' clause");
                }
                if (s.OrderBy != null && s.OrderBy.fields.Count <= 0)
                {
                    throw new ArgumentException("cannot have empty 'order by' clause");
                }
#endif
            }
            /* some tasks are only performed during debug mode */
#if DEBUG
            /* 1. debug task: propagation of toplevel statements to other manifold members required? */
            if (_parent == null)
            {
                string sproc;
                if (type_of_procedure == null)
                {
                    sproc = stmt.GetType().Name;
                }
                else
                {
                    sproc = type_of_procedure.Name;
                }
                Tracing.InfoDAL("{0} Compiled \"{1}\", a {2} command for {3}", DateTime.Now.Ticks.ToString().PadLeft(20, '0'), sproc, stmt.ToString(), db.GetProvider.ToString());
                //Tracing.VerboseDAL("at {0}", Environment.StackTrace);
                PropagateStatementCompilation(stmt);
            }
            /* 2. debug task: identify missing or inconsistent fields because some providers don't tell line numbers of wrong field names */
            /* -!- */
#endif
            return(true);
        }