public QueryTotals( DataStorage storage, string columns, string condition, object[] args, string groupBy) { this.FStorage = storage; SqlUtils.Navigation navigation = new SqlUtils.Navigation(this.FStorage.Class); this.FSql.Append("SELECT "); navigation.ReplaceCompoundIdentifiers(columns, this.FSql); StringBuilder dest1 = new StringBuilder(); navigation.ReplaceCompoundIdentifiers(condition, dest1); StringBuilder dest2 = new StringBuilder(); navigation.ReplaceCompoundIdentifiers(groupBy, dest2); this.FSql.Append(' '); navigation.AppendFromSection(this.FSql); if (dest1.Length > 0) { this.FSql.Append(" WHERE "); this.FSql.Append(dest1.ToString()); } if (dest2.Length > 0) { this.FSql.Append(" GROUP BY "); this.FSql.Append(dest2.ToString()); } SqlUtils.ConvertObjectsToInDbParams(args, out this.FSqlParamTypes, out this.FSqlParamValues); }
public ExternalAssociationNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataAssociationRef externalAssociationRef) : base(navigation, predecessor, path) { this.ExternalAssociationRef = externalAssociationRef; }
public ChildNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataChildRef childRef) : base(navigation, predecessor, path) { this.ChildRef = childRef; }
public AssociationNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataAssociationRef associationRef) : base(navigation, predecessor, path) { this.AssociationRef = associationRef; }
protected NavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path) { this.Owner = navigation; this.Predecessor = predecessor; this.Path = path; }
private void GenerateLoadSql(StringBuilder sql, ref bool onePass) { SqlUtils.Navigation navigation = new SqlUtils.Navigation(this.Class); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(" WHERE "); int startIndex = 0; int nameStart = 0; for (int nameEnd = 0; SqlUtils.FindInMetaCompoundIdentifierInSQL(this.Condition, startIndex, ref nameStart, ref nameEnd); startIndex = nameEnd) { if (nameStart > startIndex) { stringBuilder.Append(this.Condition, startIndex, nameStart - startIndex); } string ident = this.Condition.Substring(nameStart, nameEnd - nameStart); if (ident.EndsWith("Property")) { ident = ident.Substring(0, ident.Length - 8); } SqlUtils.NavigationStep step; MetadataProperty prop; navigation.RegisterIdentifier(ident, out step, out prop); if (prop == null) { stringBuilder.Append(this.Condition, nameStart, nameEnd - nameStart); } else if (step != null) { stringBuilder.AppendFormat("[{0}].[{1}]", (object)step.TargetAlias, (object)prop.DataField); } else { stringBuilder.AppendFormat("[{0}].[{1}]", (object)navigation.Alias, (object)prop.DataField); } } if (startIndex < this.Condition.Length) { stringBuilder.Append(this.Condition, startIndex, this.Condition.Length - startIndex); } if (navigation.RootSteps.Count > 0) { navigation.AppendSqlTo(sql); sql.Append(stringBuilder.ToString()); onePass = false; } else { sql.Append(this.SelectSql).AppendFormat(" [{0}]", (object)navigation.Alias); sql.Append(stringBuilder.ToString()); } }