public override MetaDataMember GetDataMember(MemberInfo mi)
        {
            if (mi == null)
            {
                throw Error.ArgumentNull(nameof(mi));
            }


            if (this.dataMemberMap == null)
            {
                lock (this.locktarget) {
                    if (this.dataMemberMap == null)
                    {
                        var map = new Dictionary <object, MetaDataMember>();

                        foreach (MetaDataMember mm in this.dataMembers)
                        {
                            map.Add(InheritanceRules.DistinguishedMemberName(mm.Member), mm);
                        }

                        this.dataMemberMap = map;
                    }
                }
            }

            object dn = InheritanceRules.DistinguishedMemberName(mi);

            MetaDataMember mdm;

            this.dataMemberMap.TryGetValue(dn, out mdm);

            return(mdm);
        }
        void Validate()
        {
            Dictionary <object, string> memberToColumn = new Dictionary <object, string>();

            foreach (MetaType type in this.InheritanceTypes)
            {
                if (type != this)
                {
                    TableAttribute[] attrs = (TableAttribute[])type.Type.GetCustomAttributes(typeof(TableAttribute), false);

                    if (attrs.Length > 0)
                    {
                        throw Error.InheritanceSubTypeIsAlsoRoot(type.Type);
                    }
                }

                foreach (MetaDataMember mem in type.PersistentDataMembers)
                {
                    if (mem.IsDeclaredBy(type))
                    {
                        if (mem.IsDiscriminator && !this.HasInheritance)
                        {
                            throw Error.NonInheritanceClassHasDiscriminator(type);
                        }

                        if (!mem.IsAssociation)
                        {
                            // validate that no database column is mapped twice

                            if (!String.IsNullOrEmpty(mem.MappedName))
                            {
                                string column;
                                object dn = InheritanceRules.DistinguishedMemberName(mem.Member);

                                if (memberToColumn.TryGetValue(dn, out column))
                                {
                                    if (column != mem.MappedName)
                                    {
                                        throw Error.MemberMappedMoreThanOnce(mem.Member.Name);
                                    }
                                }
                                else
                                {
                                    memberToColumn.Add(dn, mem.MappedName);
                                }
                            }
                        }
                    }
                }
            }
        }