Example #1
0
        protected void FinalizeColumnSpecifications()
        {
            SelectStatementTableSpecificationBase specificationBase1 = Specification.Tables.First();

            if (Specification.Columns.Count == 0)
            {
                AddColumnSelectionAll <TEntity>(specificationBase1.Alias);
            }
            AppendColumnSelectionJoinOrUnion <TEntity>(specificationBase1.Alias);
            foreach (ColumnSpecificationBase column in Specification.Columns)
            {
                ColumnSpecificationBase specification = column;
                SelectStatementTableSpecificationBase tableSpecification1 = FindTableSpecification(specification.EntityType, specification.Alias);
                ColumnSpecificationBase specificationBase2 = Specification.JoinsColumns.Where(j =>
                {
                    if (!(j.Identifier == specification.Identifier))
                    {
                        return(j.Identifier == specification.ColumnName);
                    }
                    return(true);
                }).FirstOrDefault();
                if (specificationBase2 != null)
                {
                    SelectStatementTableSpecificationBase tableSpecification2 = FindTableSpecification(specificationBase2.EntityType, specificationBase2.Alias);
                    specification.Table  = tableSpecification2.TableName;
                    specification.Schema = tableSpecification2.Schema;
                }
                else
                {
                    specification.Table  = tableSpecification1.TableName;
                    specification.Schema = tableSpecification1.Schema;
                }
            }
        }
Example #2
0
 protected void FinalizeOrderings()
 {
     foreach (OrderSpecificationBase ordering in Specification.Orderings)
     {
         SelectStatementTableSpecificationBase tableSpecification = FindTableSpecification(ordering.EntityType, ordering.Alias);
         ordering.TableName = tableSpecification.TableName;
         ordering.Schema    = tableSpecification.Schema;
     }
 }
Example #3
0
 protected void FinalizeHavings()
 {
     foreach (SelectStatementHavingSpecificationBase having in Specification.Havings)
     {
         SelectStatementTableSpecificationBase tableSpecification = FindTableSpecification(having.EntityType, having.Alias);
         having.TableName = tableSpecification.TableName;
         having.Schema    = tableSpecification.Schema;
     }
 }
Example #4
0
 protected void FinalizeGroupings()
 {
     foreach (GroupSpecificationBase grouping in Specification.Groupings)
     {
         SelectStatementTableSpecificationBase tableSpecification = FindTableSpecification(grouping.EntityType, grouping.Alias);
         grouping.TableName = tableSpecification.TableName;
         grouping.Schema    = tableSpecification.Schema;
     }
 }
Example #5
0
 protected void FinalizeWhereConditions(IList <FilterGroupBase> filterGroups)
 {
     foreach (FilterGroupBase filterGroup in filterGroups)
     {
         foreach (FilterConditionBase condition in filterGroup.Conditions)
         {
             SelectStatementTableSpecificationBase tableSpecification = FindTableSpecification(condition.EntityType, condition.Alias);
             condition.TableName = tableSpecification.TableName;
             condition.Schema    = tableSpecification.Schema;
         }
         FinalizeWhereConditions(filterGroup.Groups);
     }
 }
Example #6
0
 protected void FinalizeJoinConditions()
 {
     foreach (JoinSpecificationBase join in Specification.Joins)
     {
         SelectStatementTableSpecificationBase tableSpecification1 = FindTableSpecification(join.LeftEntityType, join.LeftTableAlias);
         join.LeftTableName = tableSpecification1.TableName;
         join.LeftSchema    = tableSpecification1.Schema;
         SelectStatementTableSpecificationBase tableSpecification2 = FindTableSpecification(join.RightEntityType, join.RightTableAlias);
         if (tableSpecification2 != null)
         {
             join.RightTableName = tableSpecification2.TableName;
             join.RightSchema    = tableSpecification2.Schema;
         }
     }
 }
Example #7
0
        public ISelectStatement <TEntity> From(string alias = null, string tableName = null, string tableSchema = null)
        {
            SelectStatementTableSpecificationBase specificationBase = Specification.Tables.First();

            if (!string.IsNullOrEmpty(alias))
            {
                specificationBase.Alias = alias;
            }
            if (!string.IsNullOrEmpty(tableName))
            {
                specificationBase.TableName = tableName;
            }
            if (!string.IsNullOrEmpty(tableSchema))
            {
                specificationBase.Schema = tableSchema;
            }
            return(this);
        }
Example #8
0
        protected string BuildFromClause()
        {
            string seed = string.Empty;

            foreach (SelectStatementTableSpecificationBase table in Tables)
            {
                SelectStatementTableSpecificationBase specification = table;
                specification.NoLocks = NoLocks;
                seed += specification.ToString();
                if (specification.JoinType != JoinType.None)
                {
                    seed = Joins.Where(joinSpecification =>
                    {
                        if (joinSpecification.RightEntityType == specification.EntityType)
                        {
                            return(joinSpecification.RightTableAlias == specification.Alias);
                        }
                        return(false);
                    }).Aggregate(seed, (current, joinSpecification) => current + joinSpecification.ToString());
                }
            }
            return(seed);
        }