Example #1
0
        void InitFromBase(SqlTable baseTable)
        {
            if (Alias == null)
            {
                Alias = baseTable.Alias;
            }
            if (Database == null)
            {
                Database = baseTable.Database;
            }
            if (Owner == null)
            {
                Owner = baseTable.Owner;
            }
            if (PhysicalName == null)
            {
                PhysicalName = baseTable.PhysicalName;
            }

            foreach (var field in baseTable.Fields.Values)
            {
                if (!Fields.ContainsKey(field.Name))
                {
                    Fields.Add(new SqlField(field));
                }
            }

            foreach (var join in baseTable.Joins)
            {
                if (Joins.FirstOrDefault(j => j.TableName == join.TableName) == null)
                {
                    Joins.Add(join);
                }
            }
        }
        /// <summary>
        /// Traverses the join path till it reached the join that's the root of the chained joins
        /// that end with the specified <paramref name="joinMap"/>
        /// </summary>
        /// <param name="joinMap">The join map</param>
        /// <returns></returns>
        private IEnumerable <JoinMap> ComputePath(JoinMap joinMap)
        {
            // Declare the result
            var result = new List <JoinMap>();

            // Declare the current map
            var current = joinMap;

            while (current != null)
            {
                result.Add(current);

                current = Joins.FirstOrDefault(x => x.ReferencedTable == current.Table);
            }

            // Invert the list
            result.Reverse();

            // Return the result
            return(result);
        }