コード例 #1
0
ファイル: RoleInstanceOf.cs プロジェクト: whesius/allors
        internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
        {
            if (this.instanceClasses.Length == 1)
            {
                statement.Append(" (" + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + " IS NOT NULL AND ");
                statement.Append(" " + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + "=" + statement.AddParameter(this.instanceClasses[0].Id) + ")");
            }
            else if (this.instanceClasses.Length > 1)
            {
                statement.Append(" ( ");
                for (int i = 0; i < this.instanceClasses.Length; i++)
                {
                    statement.Append(" (" + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + " IS NOT NULL AND ");
                    statement.Append(" " + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + "=" + statement.AddParameter(this.instanceClasses[i].Id) + ")");
                    if (i < this.instanceClasses.Length - 1)
                    {
                        statement.Append(" OR ");
                    }
                }

                statement.Append(" ) ");
            }

            return this.Include;
        }
コード例 #2
0
ファイル: Or.cs プロジェクト: whesius/allors
        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;
        }
コード例 #3
0
ファイル: And.cs プロジェクト: whesius/allors
        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;
        }
コード例 #4
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;
        }
コード例 #5
0
ファイル: RoleContains.cs プロジェクト: whesius/allors
 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 " + extent.Session.Database.SchemaName + "." + 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;
 }
コード例 #6
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;
        }
コード例 #7
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;
        }
コード例 #8
0
ファイル: ExtentSort.cs プロジェクト: whesius/allors
        internal void BuildOrder(AllorsExtentSortSql sorter, Mapping mapping, AllorsExtentStatementSql statement)
        {
            if (sorter.Equals(this))
            {
                statement.Append(" ORDER BY " + this.roleType.SingularFullName + "_R" + ".R");
            }
            else
            {
                statement.Append(" , " + this.roleType.SingularFullName + "_R" + ".R");
            }

            statement.Append(this.sortDirection == SortDirection.Ascending ? " ASC " : " DESC ");

            if (this.subSorter != null)
            {
                this.subSorter.BuildOrder(sorter, mapping, statement);
            }
        }
コード例 #9
0
 public ObjectDataRecords(Mapping mapping, IEnumerable <long> objectIds)
 {
     this.mapping   = mapping;
     this.objectIds = objectIds;
 }
コード例 #10
0
ファイル: Initialization.cs プロジェクト: whesius/allors
 internal Initialization(Mapping mapping, Schema schema, bool useViews)
 {
     this.mapping = mapping;
     this.schema = schema;
     this.useViews = useViews;
 }
コード例 #11
0
ファイル: RoleBetweenValue.cs プロジェクト: whesius/allors
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" " + this.roleType.SingularFullName + "_R." + Mapping.ColumnNameForRole + " BETWEEN " + statement.AddParameter(this.first) + " AND " + statement.AddParameter(this.second) + " ");
     return this.Include;
 }
コード例 #12
0
ファイル: RoleLike.cs プロジェクト: whesius/allors
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" " + role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " LIKE " + statement.AddParameter(this.str));
     return this.Include;
 }
コード例 #13
0
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" (" + this.role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " IS NOT NULL AND ");
     statement.Append(" " + this.role.SingularFullName + "_R." + Mapping.ColumnNameForRole + "=" + statement.AddParameter(this.obj) + ")");
     return(this.Include);
 }
コード例 #14
0
ファイル: AssociationExists.cs プロジェクト: whesius/allors
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" " + this.association.SingularFullName + "_A." + Mapping.ColumnNameForAssociation + " IS NOT NULL");
     return this.Include;
 }
コード例 #15
0
ファイル: RoleExists.cs プロジェクト: whesius/allors
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" " + role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " IS NOT NULL");
     return Include;
 }
コード例 #16
0
ファイル: Predicate.cs プロジェクト: whesius/allors
 internal abstract bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias);
コード例 #17
0
ファイル: Equals.cs プロジェクト: whesius/allors
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" (" + alias + "." + Mapping.ColumnNameForObject + "=" + statement.AddParameter(obj) + ") ");
     return Include;
 }
コード例 #18
0
ファイル: ExtentSort.cs プロジェクト: whesius/allors
 internal void BuildSelect(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement)
 {
     statement.Append(" , " + this.roleType.SingularFullName + "_R." + Mapping.ColumnNameForRole + " ");
     if (this.subSorter != null)
     {
         this.subSorter.BuildSelect(extent, mapping, statement);
     }
 }
コード例 #19
0
ファイル: Database.cs プロジェクト: whesius/allors
        public Database(Configuration configuration)
        {
            this.connectionString = configuration.ConnectionString;
            if (this.connectionString == null)
            {
                throw new Exception("Configuration.ConnectionString is missing");
            }

            var connectionStringBuilder = new SqlConnectionStringBuilder(this.connectionString);
            var applicationName = connectionStringBuilder.ApplicationName.Trim();
            if (!string.IsNullOrWhiteSpace(applicationName))
            {
                this.id = applicationName;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(connectionStringBuilder.InitialCatalog))
                {
                    this.id = connectionStringBuilder.InitialCatalog.ToLowerInvariant();
                }
                else
                {
                    using (this.connection = new SqlConnection(this.connectionString))
                    {
                        this.connection.Open();
                        this.id = this.connection.Database.ToLowerInvariant();
                    }
                }
            }

            this.objectFactory = configuration.ObjectFactory;
            if (this.objectFactory == null)
            {
                throw new Exception("Configuration.ObjectFactory is missing");
            }

            if (!this.objectFactory.MetaPopulation.IsValid)
            {
                throw new ArgumentException("Domain is invalid");
            }

            this.objectIds = configuration.ObjectIds ?? new ObjectIdsInteger();
            this.roleCache = configuration.RoleCache ?? new RoleCache();
            this.classCache = configuration.ClassCache ?? new ClassCache();
            this.commandTimeout = configuration.CommandTimeout ?? 30;
            this.isolationLevel = configuration.IsolationLevel ?? IsolationLevel.Snapshot;
            this.schemaName = configuration.SchemaName ?? "allors";
            this.useViews = configuration.UseViews ?? true;

            if (this.ObjectIds is ObjectIdsInteger)
            {
                this.mapping = new MappingInteger(this);
            }
            else if (this.ObjectIds is ObjectIdsLong)
            {
                this.mapping = new MappingLong(this);
            }
            else
            {
                throw new NotSupportedException("ObjectIds of type " + this.ObjectIds.GetType() + " are not supported.");
            }
        }
コード例 #20
0
 internal abstract bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias);
コード例 #21
0
 internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
 {
     statement.Append(" " + this.association.SingularFullName + "_A." + Mapping.ColumnNameForAssociation + " IS NOT NULL");
     return(this.Include);
 }
コード例 #22
0
ファイル: Not.cs プロジェクト: whesius/allors
        internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias)
        {
            if (this.Include)
            {
                statement.Append(" NOT (");
                this.filter.BuildWhere(extent, mapping, statement, type, alias);
                statement.Append(")");
            }

            return this.Include;
        }