예제 #1
0
        private void GenerateFields()
        {
            myPersistentFields   = new Dictionary <string, MemberInfo>();
            myFields             = new List <string>();
            this.myEmbeddedTypes = new List <string>();
            AddFields(this.type);
            Type t         = this.type.BaseType;
            int  persCount = t.GetCustomAttributes(typeof(NDOPersistentAttribute), false).Length;

            while (persCount > 0)
            {
                AddFields(t);
                t         = t.BaseType;
                persCount = t.GetCustomAttributes(typeof(NDOPersistentAttribute), false).Length;
            }
            // Jetzt stehen alle Felder in myFields

            if (checkIfMappingsExist && !this.type.IsAbstract)
            {
                for (int i = 0; i < myFields.Count; i++)
                {
                    string            fieldName = myFields[i];
                    NDO.Mapping.Field field;
                    if ((field = cl.FindField(fieldName)) != null)
                    {
                        myFields[i] = field.Column.Name;
                    }
                    else
                    {
                        throw new NDOException(7, "Can't find mapping information for field " + cl.FullName + "." + myFields[i]);
                    }
                }
            }
        }
예제 #2
0
파일: NDOMapping.cs 프로젝트: mirkomaty/NDO
        /// <summary>
        /// Hilfsfunktion für MergeMapping
        /// </summary>
        /// <param name="c1">Klasse zum Vergleich</param>
        /// <param name="c2">Klasse zum Vergleich</param>
        /// <returns></returns>
        private bool ClassesAreDifferent(Class c1, Class c2)
        {
            var c1Fields    = c1.Fields.ToList();
            var c2Fields    = c2.Fields.ToList();
            var c1Relations = c1.Relations.ToList();
            var c2Relations = c2.Relations.ToList();

            if (c1Fields.Count != c2Fields.Count)
            {
                return(true);
            }
            if (c1Relations.Count != c2Relations.Count)
            {
                return(true);
            }
            if (c1.AssemblyName != c2.AssemblyName)
            {
                return(true);
            }
            if (c1.TableName != c2.TableName)
            {
                return(true);
            }
            if (OidsAreDifferent(c1.Oid, c2.Oid))
            {
                return(true);
            }

            foreach (Field f1 in c1Fields)
            {
                Field f2 = c2.FindField(f1.Name);
                if (null == f2)
                {
                    return(true);
                }
                if (FieldsAreDifferent(f1, f2))
                {
                    return(true);
                }
            }
            foreach (Relation r1 in c1Relations)
            {
                Relation r2 = c1.FindRelation(r1.FieldName);
                if (null == r2)
                {
                    return(true);
                }
                if (RelationsAreDifferent(r1, r2))
                {
                    return(true);
                }
            }
            return(false);
        }