internal override SqlSource VisitJoin(SqlJoin join) { if (join.JoinType == SqlJoinType.CrossApply) { // Look down the left side to see what table aliases are produced. HashSet <SqlAlias> p = SqlGatherProducedAliases.Gather(join.Left); // Look down the right side to see what table aliases are consumed. HashSet <SqlAlias> c = SqlGatherConsumedAliases.Gather(join.Right); // Look at each consumed alias and see if they are mentioned in produced. if (p.Overlaps(c)) { Annotations.Add(join, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(join.SourceExpression), SqlProvider.ProviderMode.Sql2000)); // Can't reduce because this consumed alias is produced on the left. return(base.VisitJoin(join)); } // Can turn this into a CROSS JOIN join.JoinType = SqlJoinType.Cross; return(VisitJoin(join)); } return(base.VisitJoin(join)); }
private void AnnotateSqlIncompatibility(SqlNode node, params SqlProvider.ProviderMode[] providers) { this.annotations.Add(node, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(node.SourceExpression), providers)); }
internal override SqlSelect VisitSelect(SqlSelect select) { base.VisitSelect(select); if (select.Top != null) { if (select.Top.NodeType == SqlNodeType.Value) { SqlValue val = (SqlValue)select.Top; // convert to literal value for SQL2K compatibility if (val.IsClientSpecified) { select.Top = sql.Value(val.ClrType, val.SqlType, val.Value, false, val.SourceExpression); } } else { // cannot be converted to literal value. note that this select is not SQL2K compatible this.annotations.Add(select.Top, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(select.Top.SourceExpression), SqlProvider.ProviderMode.Sql2000)); } } return(select); }