コード例 #1
0
ファイル: Extensions.cs プロジェクト: jusbuc2k/Csg.Data
        /// <summary>
        /// Renders each of the given elements into a single statement. This can be used to execute a batch.
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public static SqlStatementBatch RenderBatch(this IEnumerable <ISqlStatementElement> elements)
        {
            var writer = new SqlTextWriter();
            var args   = new SqlBuildArguments();
            int count  = 0;

            foreach (var element in elements)
            {
                count++;
                element.Render(writer, args);
                writer.WriteEndStatement();
                writer.WriteLine();
            }

            return(new SqlStatementBatch(count, writer.ToString(), args.Parameters));
        }