Exemple #1
0
        /// <summary>
        /// This is called for each new result set (in a multi-resultset query).
        /// </summary>
        private void ParseResultSet()
        {
            ColumnNameMap  = _dr.GetColumnNameMap();
            ColumnIndexMap = _dr.GetColumnIndexMap();

            if (this.CurrentOutputType != null)
            {
                this.HasChildCollectionMembers  = ModelCache.HasChildCollectionMembers(this.CurrentOutputType);
                this.HasReferencedObjectMembers = ModelCache.HasReferencedObjectMembers(this.CurrentOutputType);

                ColumnMemberLookup = ModelCache.GetColumnMemberStandardizedLookup(CurrentOutputType);

                ColumnMemberIndexMap = new List <ColumnMember>();

                foreach (var name in ColumnIndexMap)
                {
                    ColumnMember member = null;
                    if (ColumnMemberLookup.TryGetValue(name, out member))
                    {
                        ColumnMemberIndexMap.Add(member);
                    }
                }

                if (!HasReferencedObjectMembers)
                {
                    _setInstanceValuesFn = ModelCache.GetSetInstanceValuesDelegate(this);
                }
            }
        }
Exemple #2
0
        public static List <Member> GenerateMembers(Type type, Member rootMember = null, Member parentMember = null)
        {
            List <Member> members = new List <Member>();

            foreach (var cm in GenerateColumnMembers(type))
            {
                if (!cm.Skip)
                {
                    cm.Parent = parentMember;
                    cm.Root   = rootMember;
                    members.Add(cm);
                }
            }
            if (ModelCache.HasReferencedObjectMembers(type))
            {
                foreach (var rom in GenerateReferencedObjectMembers(type))
                {
                    rom.Parent = parentMember;
                    rom.Root   = rootMember;
                    members.Add(rom);
                }
            }
            if (ModelCache.HasChildCollectionMembers(type))
            {
                foreach (var ccm in GenerateChildCollectionMembers(type))
                {
                    ccm.Parent = parentMember;
                    ccm.Root   = rootMember;
                    members.Add(ccm);
                }
            }
            return(members);
        }
Exemple #3
0
        static void _generateMembersImpl(Type type, List <Member> members, Member rootMember, Member parentMember = null)
        {
            foreach (var cm in GenerateColumnMembers(type))
            {
                if (!cm.Skip)
                {
                    cm.Parent = parentMember;
                    cm.Root   = rootMember;
                    members.Add(cm);
                }
            }

            if (ModelCache.HasReferencedObjectMembers(type))
            {
                foreach (var rom in GenerateReferencedObjectMembers(type))
                {
                    rom.Parent = parentMember;
                    rom.Root   = rootMember;

                    if (!rom.HasCycle)
                    {
                        members.Add(rom);
                        _generateMembersImpl(rom.Type, members, rootMember, rom);
                    }
                }
            }

            if (ModelCache.HasChildCollectionMembers(type))
            {
                foreach (var ccp in GenerateChildCollectionMembers(type))
                {
                    ccp.Parent = parentMember;
                    ccp.Root   = rootMember;

                    if (parentMember != null && parentMember is ReferencedObjectMember)
                    {
                        ccp.ParentReferencedMember.Parent = parentMember;
                    }

                    if (!ccp.HasCycle)
                    {
                        members.Add(ccp);
                        _generateMembersImpl(ccp.CollectionType, members, rootMember, ccp);
                    }
                }
            }
        }
Exemple #4
0
 void _addJoins(Type t, List <Member> members, StringBuilder command)
 {
     if (ModelCache.HasReferencedObjectMembers(t))
     {
         foreach (var rom in members.Where(m => m is ReferencedObjectMember && !m.IsLazy && !m.AnyParent(rm => rm is ChildCollectionMember)).Select(m => m as ReferencedObjectMember))
         {
             command.AppendFormat("\n\t{0} JOIN {1} [{2}] {5} on {3} = {4}",
                                  rom.JoinType,                             //0
                                  rom.FullyQualifiedTableName,              //1
                                  rom.TableAlias,                           //2
                                  _aliasedParentColumnName(rom),            //3
                                  _aliasedColumnName(rom),                  //4
                                  rom.UseNoLock ? "(NOLOCK)" : String.Empty //5
                                  );
         }
     }
 }