internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.Include) { var root = extent.Filter.Equals(this); statement.Append(root ? " AND " : "("); var atLeastOneChildIncluded = false; foreach (var filter in this.filters) { if (atLeastOneChildIncluded) { statement.Append(" AND "); } if (filter.BuildWhere(extent, mapping, statement, type, alias)) { atLeastOneChildIncluded = true; } } if (!root) { statement.Append(")"); } return atLeastOneChildIncluded; } return false; }
internal AllorsPredicateRoleLessThanRoleSql(AllorsExtentFilteredSql extent, IRoleType role, IRoleType lessThanRole) { extent.CheckRole(role); PredicateAssertions.ValidateRoleLessThan(role, lessThanRole); this.role = role; this.lessThanRole = lessThanRole; }
public AllorsPredicateRoleInExtentSql(AllorsExtentFilteredSql extent, IRoleType role, Allors.Extent inExtent) { extent.CheckRole(role); PredicateAssertions.ValidateRoleContainedIn(role, inExtent); this.role = role; this.inExtent = (AllorsExtentSql)inExtent; }
internal AllorsPredicateRoleCompositeEqualsSql(AllorsExtentFilteredSql extent, IRoleType role, Object obj) { extent.CheckRole(role); PredicateAssertions.ValidateRoleEquals(role, obj); this.role = role; this.obj = obj; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.Include) { statement.Append("("); var atLeastOneChildIncluded = false; foreach (AllorsPredicateSql filter in this.filters) { if (atLeastOneChildIncluded) { statement.Append(" OR "); } if (filter.BuildWhere(extent, mapping, statement, type, alias)) { atLeastOneChildIncluded = true; } } statement.Append(")"); return atLeastOneChildIncluded; } return false; }
internal AllorsPredicateCompositeSql(AllorsExtentFilteredSql extent) { this.extent = extent; this.filters = new List<AllorsPredicateSql>(4); if (extent.strategy != null) { var allorsObject = extent.strategy.GetObject(); if (extent.association != null) { var role = extent.association.RoleType; if (role.IsMany) { this.AddContains(role, allorsObject); } else { this.AddEquals(role, allorsObject); } } else { var association = extent.role.AssociationType; if (association.IsMany) { this.AddContains(association, allorsObject); } else { this.AddEquals(association, allorsObject); } } } }
internal AllorsPredicateRoleInstanceofSql(AllorsExtentFilteredSql extent, IRoleType role, IObjectType instanceType, IClass[] instanceClasses) { extent.CheckRole(role); PredicateAssertions.ValidateRoleInstanceOf(role, instanceType); this.role = role; this.instanceClasses = instanceClasses; }
internal AllorsPredicateAssociationInstanceofSql(AllorsExtentFilteredSql extent, IAssociationType association, IObjectType instanceType, IClass[] instanceClasses) { extent.CheckAssociation(association); PredicateAssertions.ValidateAssociationInstanceof(association, instanceType); this.association = association; this.instanceClasses = instanceClasses; }
public RoleContainedInEnumerable(AllorsExtentFilteredSql extent, IRoleType role, IEnumerable<IObject> enumerable) { extent.CheckRole(role); PredicateAssertions.ValidateRoleContainedIn(role, this.enumerable); this.role = role; this.enumerable = enumerable; }
internal AllorsPredicateNotSql(AllorsExtentFilteredSql extent) { this.extent = extent; if (extent.strategy != null) { IObject allorsObject = extent.strategy.GetObject(); if (extent.association != null) { IRoleType role = extent.association.RoleType; if (role.IsMany) { this.AddContains(role, allorsObject); } else { this.AddEquals(role, allorsObject); } } else { IAssociationType association = extent.role.AssociationType; if (association.IsMany) { this.AddContains(association, allorsObject); } else { this.AddEquals(association, allorsObject); } } } }
internal AllorsPredicateAssociationInExtentSql(AllorsExtentFilteredSql extent, IAssociationType association, Extent inExtent) { extent.CheckAssociation(association); PredicateAssertions.AssertAssociationContainedIn(association, inExtent); this.association = association; this.inExtent = (AllorsExtentSql) inExtent; }
internal AllorsPredicateRoleGreaterThanSql(AllorsExtentFilteredSql extent, IRoleType role, IRoleType greaterThanRole) { extent.CheckRole(role); PredicateAssertions.ValidateRoleGreaterThan(role, greaterThanRole); this.role = role; this.greaterThanRole = greaterThanRole; }
internal AllorsPredicateRoleLikeSql(AllorsExtentFilteredSql extent, IRoleType role, String str) { extent.CheckRole(role); PredicateAssertions.ValidateRoleLikeFilter(role, str); this.role = role; this.str = str; }
internal AllorsPredicateRoleContainsSql(AllorsExtentFilteredSql extent, IRoleType role, IObject allorsObject) { extent.CheckRole(role); PredicateAssertions.ValidateRoleContains(role, allorsObject); this.role = role; this.allorsObject = allorsObject; }
internal AllorsPredicateAssociationContainsSql(AllorsExtentFilteredSql extent, IAssociationType association, IObject allorsObject) { extent.CheckAssociation(association); PredicateAssertions.AssertAssociationContains(association, allorsObject); this.association = association; this.allorsObject = allorsObject; }
internal AllorsPredicateRoleUnitEqualsRoleSql(AllorsExtentFilteredSql extent, IRoleType role, IRoleType equalsRole) { extent.CheckRole(role); PredicateAssertions.ValidateRoleEquals(role, equalsRole); this.role = role; this.equalsRole = equalsRole; }
public AssociationContainedInEnumerable(AllorsExtentFilteredSql extent, IAssociationType association, IEnumerable<IObject> enumerable) { extent.CheckAssociation(association); PredicateAssertions.AssertAssociationContainedIn(association, this.enumerable); this.association = association; this.enumerable = enumerable; }
internal AllorsPredicateRoleGreaterThanValueSql(AllorsExtentFilteredSql extent, IRoleType roleType, Object obj) { extent.CheckRole(roleType); PredicateAssertions.ValidateRoleGreaterThan(roleType, obj); this.roleType = roleType; this.obj = roleType.ObjectType is IUnit ? roleType.Normalize(obj) : obj; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.instanceClasses.Length == 1) { statement.Append(" (" + statement.GetJoinName(this.association) + "." + Mapping.ColumnNameForType + " IS NOT NULL AND "); statement.Append(" " + statement.GetJoinName(this.association) + "." + Mapping.ColumnNameForType + "=" + statement.AddParameter(this.instanceClasses[0].Id) + ")"); } else if (this.instanceClasses.Length > 1) { statement.Append(" ( "); for (var i = 0; i < this.instanceClasses.Length; i++) { statement.Append(" (" + statement.GetJoinName(this.association) + "." + Mapping.ColumnNameForType + " IS NOT NULL AND "); statement.Append(" " + statement.GetJoinName(this.association) + "." + Mapping.ColumnNameForType + "=" + statement.AddParameter(this.instanceClasses[i].Id) + ")"); if (i < this.instanceClasses.Length - 1) { statement.Append(" OR "); } } statement.Append(" ) "); } return this.Include; }
internal AllorsPredicateRoleBetweenRoleSql(AllorsExtentFilteredSql extent, IRoleType role, IRoleType first, IRoleType second) { extent.CheckRole(role); PredicateAssertions.ValidateRoleBetween(role, first, second); this.role = role; this.first = first; this.second = second; }
internal AllorsPredicateRoleBetweenValueSql(AllorsExtentFilteredSql extent, IRoleType roleType, Object first, Object second) { extent.CheckRole(roleType); PredicateAssertions.ValidateRoleBetween(roleType, first, second); this.roleType = roleType; this.first = roleType.ObjectType is IUnit ? roleType.Normalize(first) : first; this.second = roleType.ObjectType is IUnit ? roleType.Normalize(second) : second; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { AllorsExtentStatementSql inStatement = statement.CreateChild(inExtent, association); inStatement.UseRole(association.RoleType); statement.Append(" (" + association.SingularFullName + "_A." + Mapping.ColumnNameForRole + " IS NOT NULL AND "); statement.Append(" " + association.SingularFullName + "_A." + Mapping.ColumnNameForRole + " IN (\n"); inExtent.BuildSql(inStatement); statement.Append(" ))\n"); return Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append("\n"); statement.Append("EXISTS(\n"); statement.Append("SELECT " + Mapping.ColumnNameForObject + "\n"); statement.Append("FROM " + mapping.GetTableName(this.role) + "\n"); statement.Append("WHERE " + Mapping.ColumnNameForAssociation + "=" + alias + "." + Mapping.ColumnNameForObject + "\n"); statement.Append("AND " + Mapping.ColumnNameForRole + "=" + this.allorsObject.Strategy.ObjectId + "\n"); statement.Append(")\n"); return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { var inStatement = statement.CreateChild(this.inExtent, this.role); inStatement.UseAssociation(this.role.AssociationType); statement.Append(" (" + this.role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " IS NOT NULL AND "); statement.Append(" " + this.role.SingularFullName + "_R." + Mapping.ColumnNameForAssociation + " IN ("); this.inExtent.BuildSql(inStatement); statement.Append(" ))"); return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { var inStatement = new StringBuilder("0"); foreach (var inObject in this.enumerable) { inStatement.Append(","); inStatement.Append(inObject.Id); } statement.Append(" (" + this.role.SingularPropertyName + "_R." + Mapping.ColumnNameForRole + " IS NOT NULL AND "); statement.Append(" " + this.role.SingularPropertyName + "_R." + Mapping.ColumnNameForAssociation + " IN ("); statement.Append(inStatement.ToString()); statement.Append(" ))"); return this.Include; }
internal AllorsPredicateRoleUnitEqualsValueSql(AllorsExtentFilteredSql extent, IRoleType roleType, Object obj) { extent.CheckRole(roleType); PredicateAssertions.ValidateRoleEquals(roleType, obj); this.roleType = roleType; if (obj is Enum) { var unitType = roleType.ObjectType as IUnit; if (unitType != null && unitType.IsInteger) { this.obj = (int)obj; } else { throw new Exception("Role Object Type " + roleType.ObjectType.SingularName + " doesn't support enumerations."); } } else { this.obj = roleType.ObjectType is IUnit ? roleType.Normalize(obj) : obj; } }
internal override void Setup(AllorsExtentFilteredSql extent, AllorsExtentStatementSql statement) { statement.UseRole(this.role); }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" " + this.roleType.SingularFullName + "_R." + Mapping.ColumnNameForRole + " > " + statement.AddParameter(this.obj)); return(this.Include); }
internal override void Setup(AllorsExtentFilteredSql extent, AllorsExtentStatementSql statement) { }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" (" + alias + "." + Mapping.ColumnNameForObject + "=" + statement.AddParameter(obj) + ") "); return Include; }
internal AllorsPredicateEqualsSql(AllorsExtentFilteredSql extent, IObject obj) { PredicateAssertions.ValidateEquals(obj); this.obj = obj; }
internal override void Setup(AllorsExtentFilteredSql extent, AllorsExtentStatementSql statement) { statement.UseRole(this.roleType); }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" " + role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " BETWEEN " + first.SingularFullName + "_R." + Mapping.ColumnNameForRole + " AND " + second.SingularFullName + "_R." + Mapping.ColumnNameForRole + " "); return(Include); }
internal override void Setup(AllorsExtentFilteredSql extent, AllorsExtentStatementSql statement) { statement.UseRole(role); statement.UseRole(first); statement.UseRole(second); }