public string GenerateUpdate(
            ICollection <DbUpdateCommandTree> commandTrees,
            string rowsAffectedParameter)
        {
            if (!commandTrees.Any <DbUpdateCommandTree>())
            {
                return((string)null);
            }
            StringBuilder       sql = new StringBuilder();
            List <SqlParameter> parameters;

            sql.AppendLine(DmlSqlGenerator.GenerateUpdateSql(commandTrees.First <DbUpdateCommandTree>(), this._sqlGenerator, out parameters, false, true));
            foreach (DbUpdateCommandTree tree in commandTrees.Skip <DbUpdateCommandTree>(1))
            {
                sql.Append(DmlSqlGenerator.GenerateUpdateSql(tree, this._sqlGenerator, out parameters, false, true));
                sql.AppendLine("AND @@ROWCOUNT > 0");
                sql.AppendLine();
            }
            List <DbUpdateCommandTree> list = commandTrees.Where <DbUpdateCommandTree>((Func <DbUpdateCommandTree, bool>)(ct => ct.Returning != null)).ToList <DbUpdateCommandTree>();

            if (list.Any <DbUpdateCommandTree>())
            {
                DmlFunctionSqlGenerator.ReturningSelectSqlGenerator selectSqlGenerator = new DmlFunctionSqlGenerator.ReturningSelectSqlGenerator();
                foreach (DbUpdateCommandTree updateCommandTree in list)
                {
                    updateCommandTree.Target.Expression.Accept((DbExpressionVisitor)selectSqlGenerator);
                    updateCommandTree.Returning.Accept((DbExpressionVisitor)selectSqlGenerator);
                    updateCommandTree.Predicate.Accept((DbExpressionVisitor)selectSqlGenerator);
                }
                sql.AppendLine(selectSqlGenerator.Sql);
                sql.AppendLine();
            }
            DmlFunctionSqlGenerator.AppendSetRowsAffected(sql, rowsAffectedParameter);
            return(sql.ToString().TrimEnd());
        }
        public string GenerateDelete(
            ICollection <DbDeleteCommandTree> commandTrees,
            string rowsAffectedParameter)
        {
            StringBuilder       sql = new StringBuilder();
            List <SqlParameter> parameters;

            sql.AppendLine(DmlSqlGenerator.GenerateDeleteSql(commandTrees.First <DbDeleteCommandTree>(), this._sqlGenerator, out parameters, true, true));
            sql.AppendLine();
            foreach (DbDeleteCommandTree tree in commandTrees.Skip <DbDeleteCommandTree>(1))
            {
                sql.AppendLine(DmlSqlGenerator.GenerateDeleteSql(tree, this._sqlGenerator, out parameters, true, true));
                sql.AppendLine("AND @@ROWCOUNT > 0");
                sql.AppendLine();
            }
            DmlFunctionSqlGenerator.AppendSetRowsAffected(sql, rowsAffectedParameter);
            return(sql.ToString().TrimEnd());
        }