コード例 #1
0
        internal static void BuildNode(this Chainer node, QueryPart queryPart,
                                       BuildContext buildContext, BuildArgs buildArgs, StringBuilder sql)
        {
            if (node == null)
            {
                return;
            }

            var root = node.GetRoot();

            // snippet check
            if (root.CompilableType == Compilable.ObjectType.Snippet && node is ISnippetDisallowed)
            {
                node.Throw(QueryTalkExceptionType.InvalidSnippet, null, node.Method);
            }

            string append = null;

            if (node.Build != null && !node.SkipBuild)
            {
                // important: assign current object
                buildContext.Current = node;

                // important: store query part into the current object
                buildContext.Current.QueryPart = queryPart;

                // build
                append = node.Build(buildContext, buildArgs);

                TryThrow(node.Exception);
                TryThrow(buildContext.Exception);
            }

            if (append != null)
            {
                if (append == Text.Terminator)
                {
                    sql.TrimEnd();
                }

                sql.Append(append);

                // assure that there is always a spacing between the sql parts/clauses
                sql.S();
            }

            // check view
            if (root.CompilableType == Compilable.ObjectType.View &&
                (root.Statements.Count > 1 ||           // view can have only a single statement
                 !(node is IViewAllowed)))              // only clauses related to select statement can be contained in the view
            {
                root.CheckNodeReuseAndThrow();
                node.Throw(QueryTalkExceptionType.InvalidView, null, node.Method);
            }
        }
コード例 #2
0
 // returns Root of the chain object in null safe manner
 internal static Designer TryGetRoot(this Chainer cobj)
 {
     if (cobj != null)
     {
         if (cobj.Root is Designer)
         {
             return(cobj.GetRoot());
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
コード例 #3
0
 internal NonTranChainer(Chainer prev)
     : base(prev)
 {
     CheckNullAndThrow(Arg(() => prev, prev));
     prev.GetRoot().IsEmbeddedTransaction = false;
 }