Пример #1
0
        private void AddParentToChildJoins(DbJoin arg)
        {
            TableKey childTable = arg.Destination;
            TableKey parent     = null;
            Dictionary <int, string> localGeneratedJoins = new Dictionary <int, string> ( );


            while ((parent = childTable.Parent) != null && (arg.Source != childTable))
            {
                DbJoin join = new DbJoin(parent, childTable);

                if (!_generatedJoins.ContainsKey(join))
                {
                    var joins = _cachedJoins.GetOrAdd(join, GenerateAndAddJoinWithChild);
                    localGeneratedJoins.Add(join, joins.First( ));
                }

                childTable = parent;
            }

            if (arg.Source == childTable)
            {
                Merge(_generatedJoins, localGeneratedJoins);
            }
        }
Пример #2
0
 private void CreateJoin(DbJoin arg)
 {
     if (!AddChildToParentJoins(arg))
     {
         AddParentToChildJoins(arg);
     }
 }
Пример #3
0
        public void AddJoins(TableKey source, TableKey destination)
        {
            if (source == destination)
            {
                return;
            }

            DbJoin join = new DbJoin(source, destination);

            CreateJoin(join);
        }
Пример #4
0
        private bool AddChildToParentJoins(DbJoin arg)
        {
            TableKey childTable = arg.Source;
            TableKey parent     = null;

            while ((parent = childTable.Parent) != null && (arg.Destination != childTable))
            {
                DbJoin join = new DbJoin(childTable, parent);

                if (!_generatedJoins.ContainsKey(join))
                {
                    var joins = _cachedJoins.GetOrAdd(join, GenerateAndAddNewJoin);
                    _generatedJoins.Add(join, joins.First( ));
                }

                childTable = parent;
            }

            return(childTable == arg.Destination);
        }
Пример #5
0
        private List <string> GenerateAndAddJoinWithChild(DbJoin arg)
        {
            string joinText = GetJoinWithChild(arg.Destination);

            return(new List <string> (new string[] { joinText }));
        }
Пример #6
0
        private List <string> GenerateAndAddNewJoin(DbJoin arg)
        {
            string joinText = GetJoinWithParent(arg.Source);

            return(new List <string> (new string[] { joinText }));
        }