private ExpressionVisitorContext(SqlGenerator generator, IDictionary<string, object> parameters, ICollection<Tuple<Type, string, Column>> tempColumnMappers) { this.Generator = generator; this.Fragment = new QueryFragment(); this.Parameters = parameters; this.TableNames = new Dictionary<Type, string>(); this.TempColumnMappers = tempColumnMappers; }
internal ExpressionVisitorContext(SqlGenerator generator) { this.Generator = generator; this.Fragment = new QueryFragment(); this.Parameters = new Dictionary<string, object>(); this.TableNames = new Dictionary<Type, string>(); this.TempColumnMappers = new List<Tuple<Type, string, Column>>(); }
public abstract string ToSql(SqlGenerator generator);
public override string ToSql(SqlGenerator generator) { if (Left != null) return string.Format("{0} {1} {2}", Left.ToSql(generator), Relation, Right.ToSql(generator)); return Right.ToSql(generator); }
public override string ToSql(SqlGenerator generator) { var sb = new StringBuilder(); sb.Append(generator.DecorateName(TableName)); if (!string.IsNullOrEmpty(this.Alias)) sb.AppendFormat(" AS {0}", Alias); return sb.ToString(); }
public abstract string ToSql(SqlGenerator generator, bool withAlias = true);
public override string ToSql(SqlGenerator generator) { var sb = new StringBuilder(); sb.AppendFormat("({0})", InnerFragment.ToSql(generator)); if (!string.IsNullOrEmpty(this.Alias)) sb.AppendFormat(" AS {0}", Alias); return sb.ToString(); }
public override string ToSql(SqlGenerator generator, bool withAlias = true) { if (!string.IsNullOrEmpty(this.Alias) && withAlias) { return string.Format("{0} AS {1}", MemberName, Alias); } return MemberName; }
public string ToSql(SqlGenerator generator) { var sb = new StringBuilder(); sb.Append("Select "); if (SelectPart.Any()) { sb = SelectPart.Aggregate(sb, (s, i) => s.AppendFormat("{0},", i.ToSql(generator))); sb.Remove(sb.Length - 1, 1); } else { sb.Append("*"); } sb.Append(" From "); sb = FromPart.Aggregate(sb, (s, i) => s.AppendFormat("{0} ", i.ToSql(generator))); if (WherePart != null) { sb.AppendFormat("Where {0}", WherePart.ToSql(generator)); } if (GroupPart.Any()) { sb.Append(" Group By "); sb = GroupPart.Aggregate(sb, (s, o) => s.AppendFormat("{0},", o.ToSql(generator, false))); sb.Remove(sb.Length - 1, 1); } if (OrderPart.Any()) { sb.Append(" Order By "); sb = OrderPart.Aggregate(sb, (s, o) => s.AppendFormat("{0},", o.ToSql(generator))); sb.Remove(sb.Length - 1, 1); } if (Take.HasValue) { sb.Append(" limit "); if (Skip.HasValue) { sb.AppendFormat("{0},", Skip.Value); } sb.Append(Take.Value); } return sb.ToString(); }
public string ToSql(SqlGenerator generator) { return string.Format("{0} {1}", Column.ToSql(generator), Order); }
public override string ToSql(SqlGenerator generator, bool withAlias = true) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(TableName)) sb.AppendFormat("{0}.", generator.DecorateName(TableName)); sb.Append(generator.DecorateName(MemberName)); if (!string.IsNullOrEmpty(this.Alias) && withAlias) sb.AppendFormat(" AS {0}", Alias); return sb.ToString(); }
public override string ToSql(SqlGenerator generator) { var sb = new StringBuilder(); sb.AppendFormat("{0} ", GetJoinSql(JoinMode)); sb.Append(Table.ToSql(generator)); if (!string.IsNullOrEmpty(this.Alias)) sb.AppendFormat(" AS {0}", Alias); if (JoinMode != JoinMode.Default) { sb.AppendFormat(" On {0}", JoinCondition.ToSql(generator)); } return sb.ToString(); }
public override string ToSql(SqlGenerator generator, bool withAlias = true) { var sb = new StringBuilder(); if (this.Parameters != null && this.Parameters.Any()) sb.AppendFormat(this.Formatter, this.Parameters.Select(p => p.ToSql(generator)).ToArray()); else sb.Append(this.Formatter); if (!string.IsNullOrEmpty(this.Alias) && withAlias) sb.AppendFormat(" AS {0}", Alias); return sb.ToString(); }
internal TypeHandler(IDbConnection connection) { SqlGenerator = new SqlGenerator(connection); //parser = new QueryExpressionParser(connection); }