public void BuildOrder(ExtentStatement statement, string alias) { if (statement.Sorter.Equals(this)) { statement.Append(" ORDER BY " + alias + "." + statement.Schema.Column(this.roleType)); } else { statement.Append(" , " + alias + "." + statement.Schema.Column(this.roleType)); } if (this.direction == SortDirection.Ascending) { statement.Append(" ASC "); this.AddAscendingAppendix(statement); } else { statement.Append(" DESC "); this.AddDescendingAppendix(statement); } if (this.subSorter != null) { this.subSorter.BuildOrder(statement, alias); } }
public override bool BuildWhere(ExtentStatement statement, string alias) { var schema = statement.Schema; statement.Append(" " + alias + "." + schema.Column(this.role) + " < " + alias + "." + schema.Column(this.lessThanRole)); return(this.Include); }
public override bool BuildWhere(ExtentStatement statement, string alias) { var schema = statement.Schema; statement.Append(" " + alias + "." + schema.Column(this.roleType) + ">" + statement.AddParameter(this.obj)); return(this.Include); }
public void BuildSelect(ExtentStatement statement, string alias) { statement.Append(" , " + alias + "." + statement.Schema.Column(this.roleType) + " "); if (this.subSorter != null) { this.subSorter.BuildSelect(statement, alias); } }
private void AddDescendingAppendix(ExtentStatement statement) { var sortAppendix = this.session.SqlDatabase.DescendingSortAppendix; if (sortAppendix != null) { statement.Append(sortAppendix + " "); } }
public override bool BuildWhere(ExtentStatement statement, string alias) { if (this.Include) { statement.Append(" NOT ("); this.filter.BuildWhere(statement, alias); statement.Append(")"); } return(this.Include); }
public override string BuildSql(ExtentStatement statement) { this.LazyLoadFilter(); this.filter.Setup(statement); if (this.objectType.ExistClass) { if (this.objectType.ExistExclusiveClass) { return(this.BuildSqlWithExclusiveLeafClass(statement)); } return(this.BuildSqlWithExclusiveLeafClasses(statement)); } return(null); }
public override bool BuildWhere(ExtentStatement statement, string alias) { var schema = statement.Schema; if ((this.association.IsMany && this.association.RoleType.IsMany) || !this.association.RelationType.ExistExclusiveClasses) { statement.Append("\n"); statement.Append("EXISTS(\n"); statement.Append("SELECT " + alias + "." + schema.ObjectId + "\n"); statement.Append("FROM " + schema.Table(this.association) + "\n"); statement.Append("WHERE " + schema.AssociationId + "=" + this.allorsObject.Strategy.ObjectId + "\n"); statement.Append("AND " + schema.RoleId + "=" + alias + "." + schema.ObjectId + "\n"); statement.Append(")"); } else { statement.Append(" " + this.association.SingularFullName + "_A." + schema.ObjectId + " = " + this.allorsObject.Strategy.ObjectId); } return(this.Include); }
public override bool BuildWhere(ExtentStatement statement, string alias) { var schema = statement.Schema; var inStatement = new StringBuilder("0"); foreach (var inObject in this.enumerable) { inStatement.Append(","); inStatement.Append(inObject.Id); } if ((this.role.IsMany && this.role.RelationType.AssociationType.IsMany) || !this.role.RelationType.ExistExclusiveClasses) { statement.Append(" (" + this.role.SingularPropertyName + "_R." + schema.RoleId + " IS NOT NULL AND "); statement.Append(" " + this.role.SingularPropertyName + "_R." + schema.AssociationId + " IN ("); statement.Append(inStatement.ToString()); statement.Append(" ))"); } else { if (this.role.IsMany) { statement.Append(" (" + this.role.SingularPropertyName + "_R." + schema.ObjectId + " IS NOT NULL AND "); statement.Append(" " + this.role.SingularPropertyName + "_R." + schema.ObjectId + " IN ("); statement.Append(inStatement.ToString()); statement.Append(" ))"); } else { statement.Append(" (" + schema.Column(this.role) + " IS NOT NULL AND "); statement.Append(" " + schema.Column(this.role) + " IN ("); statement.Append(inStatement.ToString()); statement.Append(" ))"); } } return(this.Include); }
public override bool BuildWhere(ExtentStatement statement, string alias) { var schema = statement.Schema; if ((this.association.IsMany && this.association.RelationType.RoleType.IsMany) || !this.association.RelationType.ExistExclusiveClasses) { statement.Append(" " + this.association.SingularFullName + "_A." + schema.AssociationId.StatementName + " IS NOT NULL"); } else { if (this.association.RelationType.RoleType.IsMany) { statement.Append(" " + alias + "." + schema.Column(this.association) + " IS NOT NULL"); } else { statement.Append(" " + this.association.SingularFullName + "_A." + schema.ObjectId + " IS NOT NULL"); } } return(this.Include); }
public override bool BuildWhere(ExtentStatement statement, string alias) { var schema = statement.Schema; if (this.role.ObjectType is IUnit && this.equalsRole.ObjectType is IUnit) { statement.Append(" " + alias + "." + schema.Column(this.role) + "=" + alias + "." + schema.Column(this.equalsRole)); } else { var roleCompositeType = this.role.ObjectType as IComposite; var equalsRoleCompositeType = this.equalsRole.ObjectType as IComposite; if (roleCompositeType != null && roleCompositeType.ExclusiveClass != null && equalsRoleCompositeType != null && equalsRoleCompositeType.ExclusiveClass != null) { statement.Append(" " + alias + "." + schema.Column(this.role) + "=" + alias + "." + schema.Column(this.equalsRole)); } throw new NotImplementedException(); } return(this.Include); }
public override void Setup(ExtentStatement statement) { }
public override void Setup(ExtentStatement statement) { statement.UseRole(this.role); }
public override void Setup(ExtentStatement statement) { //extent.UseRole(role); }
private string BuildSqlWithExclusiveLeafClass(ExtentStatement statement) { var alias = statement.CreateAlias(); var exclusiveLeafClass = this.objectType.ExclusiveClass; if (statement.IsRoot) { statement.Append("SELECT DISTINCT " + alias + "." + this.Schema.ObjectId); if (statement.Sorter != null) { statement.Sorter.BuildSelect(statement, alias); } statement.Append(" FROM " + this.Schema.Table(exclusiveLeafClass) + " " + alias); statement.AddJoins(exclusiveLeafClass, alias); statement.AddWhere(exclusiveLeafClass, alias); if (this.filter != null) { this.filter.BuildWhere(statement, alias); } } else { // ContainedIn var inStatement = (ExtentStatementChild)statement; if (inStatement.RoleType != null) { var inRole = inStatement.RoleType; var inRelationType = inRole.RelationType; if (inRelationType.Multiplicity == Multiplicity.ManyToMany || !inRelationType.ExistExclusiveClasses) { statement.Append("SELECT " + inRole.AssociationType.SingularFullName + "_A." + this.Schema.AssociationId); } else { if (inRole.IsMany) { statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); } else { statement.Append("SELECT " + inRole.AssociationType.SingularFullName + "_A." + this.Schema.Column(inRole.AssociationType)); } } statement.Append(" FROM " + this.Schema.Table(exclusiveLeafClass) + " " + alias); statement.AddJoins(exclusiveLeafClass, alias); var wherePresent = statement.AddWhere(exclusiveLeafClass, alias); var filterUsed = false; if (this.filter != null) { filterUsed = this.filter.BuildWhere(statement, alias); } if (wherePresent || filterUsed) { statement.Append(" AND "); } else { statement.Append(" WHERE "); } if (inRelationType.Multiplicity == Multiplicity.ManyToMany || !inRelationType.ExistExclusiveClasses) { statement.Append(inRole.AssociationType.SingularFullName + "_A." + this.Schema.AssociationId + " IS NOT NULL "); } else { if (inRole.IsMany) { statement.Append(alias + "." + this.Schema.Column(inRole.AssociationType) + " IS NOT NULL "); } else { statement.Append(inRole.AssociationType.SingularFullName + "_A." + this.Schema.Column(inRole.AssociationType) + " IS NOT NULL "); } } } else { if (statement.IsRoot) { statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); if (statement.Sorter != null) { statement.Sorter.BuildSelect(statement); } } else { statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); } statement.Append(" FROM " + this.Schema.Table(exclusiveLeafClass) + " " + alias); statement.AddJoins(exclusiveLeafClass, alias); statement.AddWhere(exclusiveLeafClass, alias); if (this.filter != null) { this.filter.BuildWhere(statement, alias); } } } return(alias); }
public override void Setup(ExtentStatement statement) { statement.UseAssociation(this.association); statement.UseAssociationInstance(this.association); }
private string BuildSqlWithExclusiveLeafClasses(ExtentStatement statement) { if (statement.IsRoot) { var leafClasses = this.objectType.Classes.ToArray(); for (var i = 0; i < leafClasses.Length; i++) { var alias = statement.CreateAlias(); var leafClass = leafClasses[i]; statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); if (statement.Sorter != null) { statement.Sorter.BuildSelect(statement); } statement.Append(" FROM " + this.Schema.Table(leafClass) + " " + alias); statement.AddJoins(leafClass, alias); statement.AddWhere(leafClass, alias); if (this.filter != null) { this.filter.BuildWhere(statement, alias); } if (i < leafClasses.Length - 1) { statement.Append("\nUNION\n"); } } } else { var inStatement = (ExtentStatementChild)statement; if (inStatement.RoleType != null) { var useUnion = false; foreach (var leafClass in this.objectType.Classes) { var inRole = inStatement.RoleType; var inRelationType = inRole.RelationType; if (!((IComposite)inRole.ObjectType).Classes.Contains(leafClass)) { continue; } if (useUnion) { statement.Append("\nUNION\n"); } else { useUnion = true; } var alias = statement.CreateAlias(); if (inRelationType.Multiplicity == Multiplicity.ManyToMany || !inRelationType.ExistExclusiveClasses) { statement.Append("SELECT " + inRole.AssociationType.SingularFullName + "_A." + this.Schema.AssociationId); } else { if (inRole.IsMany) { statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); } else { statement.Append("SELECT " + inRole.AssociationType.SingularFullName + "_A." + this.Schema.Column(inRole.AssociationType)); } } statement.Append(" FROM " + this.Schema.Table(leafClass) + " " + alias); statement.AddJoins(leafClass, alias); var wherePresent = statement.AddWhere(leafClass, alias); var filterUsed = false; if (this.filter != null) { filterUsed = this.filter.BuildWhere(statement, alias); } if (wherePresent || filterUsed) { statement.Append(" AND "); } else { statement.Append(" WHERE "); } if (inRelationType.Multiplicity == Multiplicity.ManyToMany || !inRelationType.ExistExclusiveClasses) { statement.Append(inRole.AssociationType.SingularFullName + "_A." + this.Schema.AssociationId + " IS NOT NULL "); } else { if (inRole.IsMany) { statement.Append(alias + "." + this.Schema.Column(inRole.AssociationType) + " IS NOT NULL "); } else { statement.Append(inRole.AssociationType.SingularFullName + "_A." + this.Schema.Column(inRole.AssociationType) + " IS NOT NULL "); } } } } else { var leafClasses = this.objectType.Classes.ToArray(); for (var i = 0; i < leafClasses.Length; i++) { var alias = statement.CreateAlias(); var leafClass = leafClasses[i]; if (statement.IsRoot) { statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); if (statement.Sorter != null) { statement.Sorter.BuildSelect(statement); } } else { statement.Append("SELECT " + alias + "." + this.Schema.ObjectId); } statement.Append(" FROM " + this.Schema.Table(leafClass) + " " + alias); statement.AddJoins(leafClass, alias); statement.AddWhere(leafClass, alias); if (this.filter != null) { this.filter.BuildWhere(statement, alias); } if (i < leafClasses.Length - 1) { statement.Append("\nUNION\n"); } } } } return(null); }
public override void Setup(ExtentStatement statement) { statement.UseRole(this.role); statement.UseRole(this.first); statement.UseRole(this.second); }
public abstract string BuildSql(ExtentStatement statement);