Пример #1
0
        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;
        }
Пример #2
0
 internal AllorsPredicateRoleLessThanRoleSql(AllorsExtentFilteredSql extent, IRoleType role, IRoleType lessThanRole)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleLessThan(role, lessThanRole);
     this.role = role;
     this.lessThanRole = lessThanRole;
 }
Пример #3
0
 public AllorsPredicateRoleInExtentSql(AllorsExtentFilteredSql extent, IRoleType role, Allors.Extent inExtent)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleContainedIn(role, inExtent);
     this.role = role;
     this.inExtent = (AllorsExtentSql)inExtent;
 }
Пример #4
0
 internal AllorsPredicateRoleCompositeEqualsSql(AllorsExtentFilteredSql extent, IRoleType role, Object obj)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleEquals(role, obj);
     this.role = role;
     this.obj = obj;
 }
Пример #5
0
        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;
        }
Пример #6
0
        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);
                    }
                }
            }
        }
Пример #7
0
 internal AllorsPredicateRoleInstanceofSql(AllorsExtentFilteredSql extent, IRoleType role, IObjectType instanceType, IClass[] instanceClasses)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleInstanceOf(role, instanceType);
     this.role = role;
     this.instanceClasses = instanceClasses;
 }
Пример #8
0
 internal AllorsPredicateAssociationInstanceofSql(AllorsExtentFilteredSql extent, IAssociationType association, IObjectType instanceType, IClass[] instanceClasses)
 {
     extent.CheckAssociation(association);
     PredicateAssertions.ValidateAssociationInstanceof(association, instanceType);
     this.association = association;
     this.instanceClasses = instanceClasses;
 }
Пример #9
0
 public RoleContainedInEnumerable(AllorsExtentFilteredSql extent, IRoleType role, IEnumerable<IObject> enumerable)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleContainedIn(role, this.enumerable);
     this.role = role;
     this.enumerable = enumerable;
 }
Пример #10
0
        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);
                    }
                }
            }
        }
Пример #11
0
 internal AllorsPredicateAssociationInExtentSql(AllorsExtentFilteredSql extent, IAssociationType association, Extent inExtent)
 {
     extent.CheckAssociation(association);
     PredicateAssertions.AssertAssociationContainedIn(association, inExtent);
     this.association = association;
     this.inExtent = (AllorsExtentSql) inExtent;
 }
Пример #12
0
 internal AllorsPredicateRoleGreaterThanSql(AllorsExtentFilteredSql extent, IRoleType role, IRoleType greaterThanRole)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleGreaterThan(role, greaterThanRole);
     this.role = role;
     this.greaterThanRole = greaterThanRole;
 }
Пример #13
0
 internal AllorsPredicateRoleLikeSql(AllorsExtentFilteredSql extent, IRoleType role, String str)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleLikeFilter(role, str);
     this.role = role;
     this.str = str;
 }
Пример #14
0
 internal AllorsPredicateRoleContainsSql(AllorsExtentFilteredSql extent, IRoleType role, IObject allorsObject)
 {
     extent.CheckRole(role);
     PredicateAssertions.ValidateRoleContains(role, allorsObject);
     this.role = role;
     this.allorsObject = allorsObject;
 }
Пример #15
0
 internal AllorsPredicateAssociationContainsSql(AllorsExtentFilteredSql extent, IAssociationType association, IObject allorsObject)
 {
     extent.CheckAssociation(association);
     PredicateAssertions.AssertAssociationContains(association, allorsObject);
     this.association = association;
     this.allorsObject = allorsObject;
 }
Пример #16
0
 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;
 }
Пример #18
0
 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;
 }
Пример #19
0
        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;
        }
Пример #20
0
 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;
 }
Пример #21
0
 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;
 }
Пример #22
0
        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;
        }
Пример #23
0
 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;
 }
Пример #24
0
        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;
        }
Пример #25
0
        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;
        }
Пример #26
0
 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;
     }
 }
Пример #27
0
 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);
 }
Пример #29
0
 internal override void Setup(AllorsExtentFilteredSql extent, AllorsExtentStatementSql statement)
 {
 }
Пример #30
0
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" (" + alias + "." + Mapping.ColumnNameForObject + "=" + statement.AddParameter(obj) + ") ");
     return Include;
 }
Пример #31
0
 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);
 }