internal static string GenerateInsertSql(DbInsertCommandTree tree, EFOracleProviderManifest providerManifest, EFOracleVersion sqlVersion, out List <OracleParameter> parameters)
        {
            StringBuilder commandText = new StringBuilder(256);

            DmlSqlGenerator.ExpressionTranslator translator = new DmlSqlGenerator.ExpressionTranslator(commandText, (DbModificationCommandTree)tree, null != tree.Returning, sqlVersion);
            commandText.Append("insert into ");
            tree.Target.Expression.Accept((DbExpressionVisitor)translator);
            if (0 < tree.SetClauses.Count)
            {
                commandText.Append("(");
                bool flag1 = true;
                foreach (DbSetClause setClause in (IEnumerable <DbModificationClause>)tree.SetClauses)
                {
                    if (flag1)
                    {
                        flag1 = false;
                    }
                    else
                    {
                        commandText.Append(", ");
                    }
                    setClause.Property.Accept((DbExpressionVisitor)translator);
                }
                commandText.AppendLine(")");
                bool flag2 = true;
                commandText.Append("values (");
                foreach (DbSetClause setClause in (IEnumerable <DbModificationClause>)tree.SetClauses)
                {
                    if (flag2)
                    {
                        flag2 = false;
                    }
                    else
                    {
                        commandText.Append(", ");
                    }
                    setClause.Value.Accept((DbExpressionVisitor)translator);
                    translator.RegisterMemberValue(setClause.Property, setClause.Value);
                }
                commandText.AppendLine(")");
            }
            else
            {
                commandText.AppendLine().AppendLine(" values (default)");
            }
            DmlSqlGenerator.GenerateReturningSql(commandText, (DbModificationCommandTree)tree, translator, tree.Returning, providerManifest, sqlVersion, false);
            parameters = translator.Parameters;
            return(commandText.ToString());
        }
        internal static string GenerateUpdateSql(DbUpdateCommandTree tree, EFOracleProviderManifest providerManifest, EFOracleVersion sqlVersion, out List <OracleParameter> parameters)
        {
            StringBuilder commandText = new StringBuilder(256);

            DmlSqlGenerator.ExpressionTranslator translator = new DmlSqlGenerator.ExpressionTranslator(commandText, (DbModificationCommandTree)tree, null != tree.Returning, sqlVersion);
            int count = tree.SetClauses.Count;

            commandText.Append("update ");
            tree.Target.Expression.Accept((DbExpressionVisitor)translator);
            commandText.AppendLine();
            bool flag = true;

            commandText.Append("set ");
            foreach (DbSetClause setClause in (IEnumerable <DbModificationClause>)tree.SetClauses)
            {
                if (flag)
                {
                    flag = false;
                }
                else
                {
                    commandText.Append(", ");
                }
                setClause.Property.Accept((DbExpressionVisitor)translator);
                commandText.Append(" = ");
                setClause.Value.Accept((DbExpressionVisitor)translator);
            }
            if (flag)
            {
                commandText.Append("[place_holder] ");
            }
            commandText.AppendLine();
            commandText.Append("where ");
            tree.Predicate.Accept((DbExpressionVisitor)translator);
            if (flag)
            {
                string str      = commandText.ToString();
                int    num      = str.IndexOf("where ");
                string newValue = str.Substring(num + "where ".Length).Replace("(", "").Replace(")", "").Replace(" and ", " ,");
                commandText.Replace("[place_holder]", newValue);
            }
            commandText.AppendLine();
            DmlSqlGenerator.GenerateReturningSql(commandText, (DbModificationCommandTree)tree, translator, tree.Returning, providerManifest, sqlVersion, true);
            parameters = translator.Parameters;
            return(commandText.ToString());
        }
 public override void Visit(DbPropertyExpression expression)
 {
     this._commandText.Append(DmlSqlGenerator.GenerateMemberTSql(expression.Property));
 }
        private static void GenerateReturningSql(StringBuilder commandText, DbModificationCommandTree tree, DmlSqlGenerator.ExpressionTranslator translator, DbExpression returning, EFOracleProviderManifest providerManifest, EFOracleVersion sqlVersion, bool isUpdate)
        {
            if (returning == null)
            {
                return;
            }
            EntitySetBase target        = ((DbScanExpression)tree.Target.Expression).Target;
            StringBuilder stringBuilder = new StringBuilder(50);

            stringBuilder.Append("declare\n");
            Dictionary <EdmMember, string> dictionary = new Dictionary <EdmMember, string>();

            foreach (EdmMember member in target.ElementType.Members)
            {
                ReadOnlyMetadataCollection <Facet> facets = ((TypeUsage)member.MetadataProperties["TypeUsage"].Value).Facets;
                string empty = string.Empty;
                if (facets.Contains("StoreGeneratedPattern"))
                {
                    string str = facets["StoreGeneratedPattern"].Value.ToString();
                    if (!string.IsNullOrEmpty(str))
                    {
                        if (isUpdate && str.ToUpperInvariant() == "COMPUTED")
                        {
                            dictionary[member] = str;
                        }
                        else if (!isUpdate && (str.ToUpperInvariant() == "COMPUTED" || str.ToUpperInvariant() == "IDENTITY"))
                        {
                            dictionary[member] = str;
                        }
                    }
                }
                if (dictionary.ContainsKey(member))
                {
                    stringBuilder.Append(DmlSqlGenerator.GenerateMemberTSql(member));
                    stringBuilder.Append(" ");
                    stringBuilder.Append(SqlGenerator.GetSqlPrimitiveType((DbProviderManifest)providerManifest, sqlVersion, member.TypeUsage));
                    stringBuilder.Append(";\n");
                }
            }
            stringBuilder.Append("begin\n");
            commandText.Insert(0, stringBuilder.ToString());
            OracleParameter parameter = translator.CreateParameter(OracleDbType.RefCursor, ParameterDirection.Output);

            commandText.Append("returning\n");
            string str1 = string.Empty;

            foreach (EdmMember member in target.ElementType.Members)
            {
                if (dictionary.ContainsKey(member))
                {
                    commandText.Append(str1);
                    commandText.Append(DmlSqlGenerator.GenerateMemberTSql(member));
                    str1 = ", ";
                }
            }
            commandText.Append(" into\n");
            string str2 = string.Empty;

            foreach (EdmMember member in target.ElementType.Members)
            {
                if (dictionary.ContainsKey(member))
                {
                    commandText.Append(str2);
                    commandText.Append(DmlSqlGenerator.GenerateMemberTSql(member));
                    str2 = ", ";
                }
            }
            commandText.Append(";\n");
            commandText.Append("open ");
            commandText.Append(parameter.ParameterName);
            commandText.Append(" for select\n");
            string str3 = string.Empty;

            foreach (EdmMember member in target.ElementType.Members)
            {
                if (dictionary.ContainsKey(member))
                {
                    commandText.Append(str3);
                    commandText.Append(DmlSqlGenerator.GenerateMemberTSql(member));
                    commandText.Append(" as ");
                    commandText.Append(DmlSqlGenerator.GenerateMemberTSql(member));
                    str3 = ", ";
                }
            }
            commandText.Append(" from dual;\n");
            commandText.Append("end;");
        }