internal static bool UseGeneratedValuesVariable(DbInsertCommandTree tree, SqlVersion sqlVersion)
        {
            bool flag1 = false;

            if (sqlVersion > SqlVersion.Sql8 && tree.Returning != null)
            {
                HashSet <EdmMember> edmMemberSet = new HashSet <EdmMember>(tree.SetClauses.Cast <DbSetClause>().Select <DbSetClause, EdmMember>((Func <DbSetClause, EdmMember>)(s => ((DbPropertyExpression)s.Property).Property)));
                bool flag2 = false;
                foreach (EdmMember keyMember in ((DbScanExpression)tree.Target.Expression).Target.ElementType.KeyMembers)
                {
                    if (!edmMemberSet.Contains(keyMember))
                    {
                        if (flag2)
                        {
                            flag1 = true;
                            break;
                        }
                        flag2 = true;
                        if (!DmlSqlGenerator.IsValidScopeIdentityColumnType(keyMember.TypeUsage))
                        {
                            flag1 = true;
                            break;
                        }
                    }
                }
            }
            return(flag1);
        }
 internal static void GenerateReturningSql(
     SqlStringBuilder commandText,
     DbModificationCommandTree tree,
     EntityType tableType,
     DmlSqlGenerator.ExpressionTranslator translator,
     DbExpression returning,
     bool useGeneratedValuesVariable)
 {
     if (returning == null)
     {
         return;
     }
     commandText.AppendKeyword("select ");
     if (useGeneratedValuesVariable)
     {
         translator.PropertyAlias = "t";
     }
     returning.Accept((DbExpressionVisitor)translator);
     if (useGeneratedValuesVariable)
     {
         translator.PropertyAlias = (string)null;
     }
     commandText.AppendLine();
     if (useGeneratedValuesVariable)
     {
         commandText.AppendKeyword("from ");
         commandText.Append("@generated_keys");
         commandText.AppendKeyword(" as ");
         commandText.Append("g");
         commandText.AppendKeyword(" join ");
         tree.Target.Expression.Accept((DbExpressionVisitor)translator);
         commandText.AppendKeyword(" as ");
         commandText.Append("t");
         commandText.AppendKeyword(" on ");
         string keyword = string.Empty;
         foreach (EdmMember keyMember in tableType.KeyMembers)
         {
             commandText.AppendKeyword(keyword);
             keyword = " and ";
             commandText.Append("g.");
             string memberTsql = DmlSqlGenerator.GenerateMemberTSql(keyMember);
             commandText.Append(memberTsql);
             commandText.Append(" = t.");
             commandText.Append(memberTsql);
         }
         commandText.AppendLine();
         commandText.AppendKeyword("where @@ROWCOUNT > 0");
     }
     else
     {
         commandText.AppendKeyword("from ");
         tree.Target.Expression.Accept((DbExpressionVisitor)translator);
         commandText.AppendLine();
         commandText.AppendKeyword("where @@ROWCOUNT > 0");
         EntitySetBase target = ((DbScanExpression)tree.Target.Expression).Target;
         bool          flag   = false;
         foreach (EdmMember keyMember in target.ElementType.KeyMembers)
         {
             commandText.AppendKeyword(" and ");
             commandText.Append(DmlSqlGenerator.GenerateMemberTSql(keyMember));
             commandText.Append(" = ");
             SqlParameter sqlParameter;
             if (translator.MemberValues.TryGetValue(keyMember, out sqlParameter))
             {
                 commandText.Append(sqlParameter.ParameterName);
             }
             else
             {
                 if (flag)
                 {
                     throw new NotSupportedException(Strings.Update_NotSupportedServerGenKey((object)target.Name));
                 }
                 if (!DmlSqlGenerator.IsValidScopeIdentityColumnType(keyMember.TypeUsage))
                 {
                     throw new InvalidOperationException(Strings.Update_NotSupportedIdentityType((object)keyMember.Name, (object)keyMember.TypeUsage.ToString()));
                 }
                 commandText.Append("scope_identity()");
                 flag = true;
             }
         }
     }
 }