Пример #1
0
        public void MergeNewConnStringClassChanged()
        {
            string file1 = "File1.Xml";
            string file2 = "File2.Xml";

            NDOMapping map1 = NDOMapping.Create(file1);

            map1.AddStandardClass(classMitarbeiter, assName, null);
            ((Connection)map1.Connections[0]).Name = "Alter ConnectionString";
            map1.Save();

            NDOMapping map2 = NDOMapping.Create(file2);

            map2.AddStandardClass(classMitarbeiter, assName, null);
            ((Connection)map2.Connections[0]).Name = "Neuer ConnectionString";
            ((Class)map2.Classes[0]).AssemblyName  = "New Assembly-Name";
            map2.Save();

            map1 = new NDOMapping(file1);
            map2 = new NDOMapping(file2);

            map1.MergeMapping(map2);
            Assert.AreEqual(2, map1.Connections.Count, "Falsche Anzahl Connections");
            Assert.AreEqual(1, map1.Classes.Count, "Falsche Anzahl Klassen");
            Class c = map1.FindClass(classMitarbeiter);

            Assert.NotNull(c, "Mitarbeiter nicht gefunden");
            Assert.AreEqual("C1", c.ConnectionId, "Connection falsch");

            File.Delete(file1);
            File.Delete(file2);
        }
Пример #2
0
        public NDOMappingNode(NDOMapping mapping) : base("NDOMapping", mapping)
        {
            this.ImageIndex         = 13;
            this.SelectedImageIndex = 13;

            TreeNode classesNode;
            TreeNode connectionsNode;

            classesNode                        = new TreeNode("Classes");
            connectionsNode                    = new TreeNode("Connections");
            connectionsNode.ImageIndex         = 12;
            connectionsNode.SelectedImageIndex = 12;
            classesNode.ImageIndex             = 0;
            classesNode.SelectedImageIndex     = 0;
            this.Nodes.Add(classesNode);
            List <Class> sortedClasses = mapping.Classes.ToList();

            sortedClasses.Sort();
            foreach (Class cl in sortedClasses)
            {
                classesNode.Nodes.Add(new ClassNode(cl));
            }
            this.Nodes.Add(connectionsNode);
            foreach (Connection conn in mapping.Connections)
            {
                connectionsNode.Nodes.Add(new ConnectionNode(conn));
            }

            classesNode.Expand();
            this.Expand();
        }
Пример #3
0
        public void MergeNewConnStringFromDummy2()
        {
            string file1 = "File1.Xml";
            string file2 = "File2.Xml";

            NDOMapping map1 = NDOMapping.Create(file1);

            map1.AddStandardClass(classMitarbeiter, assName, null);
            map1.Save();

            NDOMapping map2 = NDOMapping.Create(file2);

            map2.AddStandardClass(classMitarbeiter, assName, null);
            map2.Save();

            map1 = new NDOMapping(file1);
            map2 = new NDOMapping(file2);

            Assert.AreEqual(Connection.DummyConnectionString, ((Connection)map1.Connections[0]).Name, "Must be dummy connection");
            Assert.AreEqual(Connection.DummyConnectionString, ((Connection)map2.Connections[0]).Name, "Must be dummy connection");
            ((Connection)map1.Connections[0]).Name = "Some new string";

            map1.MergeMapping(map2);
            Assert.AreEqual(1, map1.Connections.Count, "Falsche Anzahl Connections");
            Class c = map1.FindClass(classMitarbeiter);

            Assert.NotNull(c, "Mitarbeiter nicht gefunden");
            Assert.AreEqual("C0", c.ConnectionId, "Connection falsch");

            File.Delete(file1);
            File.Delete(file2);
        }
Пример #4
0
        public static PersistenceManager NewPersistenceManager(TransactionMode transactionMode = TransactionMode.Optimistic)
        {
            //string path = Path.Combine( Path.GetDirectoryName( typeof( PmFactory ).Assembly.Location ), "NDOMapping.xml" );
            string path = @"C:\Projekte\NDO\IntegrationTests\NDOUnitTests\bin\Debug\NDOMapping.xml";

            PersistenceManager pm;

            lock (lockObject)
            {
                if (mapping != null)
                {
                    pm = new PersistenceManager(mapping);
                }
                else
                {
                    pm      = new PersistenceManager(path);
                    mapping = pm.NDOMapping;
                }
            }

            pm.TransactionMode = transactionMode;
            //PersistenceManager pm = new PersistenceManager();
//			pm.LogPath = Path.GetDirectoryName(path);
//			pm.RegisterConnectionListener(new OpenConnectionListener(ConnectionGenerator.OnConnection));

//			pm.TransactionMode = TransactionMode.Pessimistic;
            Connection conn = (Connection)pm.NDOMapping.Connections.First();

#if ORACLE || FIREBIRD || POSTGRE
            pm.IdGenerationEvent        += new NDO.IdGenerationHandler(IdGenerator.OnIdGenerationEvent);
            IdGenerator.ConnectionString = ((Connection)pm.NDOMapping.Connections.First()).Name;
#endif
            pm.VerboseMode = false;
            return(pm);
        }
Пример #5
0
        public void MergeEqualNewConnName()
        {
            string file1 = "File1.Xml";
            string file2 = "File2.Xml";

            NDOMapping map1 = NDOMapping.Create(file1);

            map1.AddStandardClass(classMitarbeiter, assName, null);

            map1.Save();

            NDOMapping map2 = NDOMapping.Create(file2);

            map2.AddStandardClass(classMitarbeiter, assName, null);
            ((Connection)map2.Connections[0]).ID = "C1";
            map2.Save();

            map1 = new NDOMapping(file1);
            map2 = new NDOMapping(file2);

            map1.MergeMapping(map2);
            Assert.AreEqual(1, map1.Classes.Count, "Falsche Anzahl Klassen");
            Assert.AreEqual(1, map1.Connections.Count, "Falsche Anzahl Connections");

            File.Delete(file1);
            File.Delete(file2);
        }
Пример #6
0
        static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("ExecuteSqlBatch: usage: ExecuteSqlBatch batchfile mapping-file");
                return(-1);
            }
            Console.WriteLine("ExecuteSqlBatch: " + args[0] + " " + args[1]);
            if (!File.Exists(args[0]))
            {
                Console.WriteLine("ExecuteSqlBatch: can't find file " + args[0]);
                return(-2);
            }
            NDOMapping mapping = new NDOMapping(args[1]);

            if (mapping.Connections.Count() != 1)
            {
                Console.WriteLine(String.Format("ExecuteSqlBatch: Wrong count of connections: {0} in mapping file {1}", mapping.Connections.Count(), args[1]));
                return(-3);
            }
            Connection conn     = (Connection)mapping.Connections.First();
            IProvider  provider = NDOProviderFactory.Instance[conn.Type];

            if (provider == null)
            {
                Console.WriteLine("ExecuteSqlBatch: NDO provider not found: " + conn.Type);
                return(-4);
            }
            Console.WriteLine(String.Format("Executing batch '{0}' on connection '{2}', db type = '{1}'", args[0], conn.Type, conn.Name));
            StreamReader sr = new StreamReader(args[0], System.Text.Encoding.Default);
            string       s  = sr.ReadToEnd();

            sr.Close();
            string[]      arr = s.Split(';');
            IDbConnection cn  = provider.NewConnection(conn.Name);

            cn.Open();
            IDbCommand cmd    = provider.NewSqlCommand(cn);
            int        result = 0;

            foreach (string statement in arr)
            {
                if (statement.Trim() != string.Empty)
                {
                    try
                    {
                        cmd.CommandText = statement;
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            cn.Close();
            Console.WriteLine("ExecuteSqlBatch ready");

            return(result);
        }
Пример #7
0
        public void AnlegenNNRelation()
        {
            string     testFile = "Test.Xml";
            NDOMapping mapping  = NDOMapping.Create(testFile);
            Class      c        = mapping.AddStandardClass(classMitarbeiter, assName, null);

            c.AddStandardRelation("dieReisen", "Reisekosten.Reise", false, "", false, false);
            c = mapping.AddStandardClass("Reisekosten.Reise", assName, null);
            c.AddStandardRelation("dieMitarbeiter", classMitarbeiter, false, "", false, false);
            mapping.Save();
            mapping = new NDOMapping(testFile);
            Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection");
            Assert.AreEqual(2, mapping.Classes.Count, "Keine Klasse");
            c = (Class)mapping.FindClass(classMitarbeiter);
            Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch");
            Assert.NotNull(c.Oid, "Keine Oid");
            Assert.AreEqual(1, c.Relations.Count, "Keine Relation");
            Relation r = c.FindRelation("dieReisen");

            Assert.NotNull(r, "Relation dieReisen nicht gefunden");
            Assert.AreEqual("IDMitarbeiter", ((ForeignKeyColumn)r.ForeignKeyColumns[0]).Name, "ForeignKeyColumnName falsch");
            Assert.AreEqual("n:n", r.GetRelationType(), "Relationstyp falsch");
            Assert.AreEqual("IDReise", ((ForeignKeyColumn)r.MappingTable.ChildForeignKeyColumns[0]).Name, "ChildForeignKeyColumnName von MappingTable falsch");
            Assert.AreEqual("relMitarbeiterReise", r.MappingTable.TableName, "TableName von MappingTable falsch");
            c = mapping.FindClass("Reisekosten.Reise");
            r = c.FindRelation("dieMitarbeiter");
            Assert.NotNull(r, "Relation dieMitarbeiter nicht gefunden");
            Assert.AreEqual("relMitarbeiterReise", r.MappingTable.TableName, "TableName von MappingTable falsch");
            Assert.AreEqual("n:n", r.GetRelationType(), "Relationstyp falsch");
            Assert.AreEqual("IDReise", ((ForeignKeyColumn)r.ForeignKeyColumns[0]).Name, "ForeignKeyColumnName falsch");
            Assert.AreEqual("IDMitarbeiter", ((ForeignKeyColumn)r.MappingTable.ChildForeignKeyColumns[0]).Name, "ChildForeignKeyColumnName von MappingTable falsch");
        }
Пример #8
0
        public AssemblyNode(Assembly ass, NDOMapping mappings)
        {
            this.mappings  = mappings;
            this.shortName = ass.FullName.Substring(0, ass.FullName.IndexOf(','));
            string dllName = ass.Location;

            try
            {
                Type[] theTypes = ass.GetTypes();
            }
            catch (ReflectionTypeLoadException tlex)
            {
                string s = string.Empty;
                foreach (Exception ex in tlex.LoaderExceptions)
                {
                    s += ex.Message + "\r\n";
                }
                throw new Exception("AssemblyNode: ReflectionTypeLoadException occured: " + s);
            }
            AnalyzeTypes(ass.GetTypes());
            this.fullName = ass.FullName;
            object[] attrs = ass.GetCustomAttributes(false);
            this.isEnhanced  = (HasEnhancedAttribute(attrs));
            this.oidTypeName = GetOidTypeNameFromAttributes(attrs);
            DetermineTargetFramework(attrs);
        }
Пример #9
0
        public SchemaGenerator(Class cl, NDOMapping mappings, DataSet dsSchema)
        {
            this.mappings = mappings;
            this.dsSchema = dsSchema;
            this.c        = cl;
            FieldMap fieldMap = new FieldMap(cl);

            this.persistentFields = fieldMap.PersistentFields;
            this.supportsGuidType = CheckGuidType();
        }
Пример #10
0
 public SchemaGenerator(Class c, NDOMapping mappings, DataSet dsSchema, MessageAdapter messages, Hashtable allSortedFields, ClassHashtable allPersistentClasses, bool verboseMode)
 {
     this.mappings        = mappings;
     this.messages        = messages;
     this.dsSchema        = dsSchema;
     this.allSortedFields = allSortedFields;
     this.c = c;
     this.allPersistentClasses = allPersistentClasses;
     this.verboseMode          = verboseMode;
 }
Пример #11
0
        /// <summary>
        /// Constructs a PersistenceManagerBase object using the mapping object.
        /// </summary>
        /// <param name="mapping"></param>
        public PersistenceManagerBase(NDOMapping mapping)
        {
            var localMappings = mapping as Mappings;

            if (localMappings == null)
            {
                throw new ArgumentException("The mapping must be constructed by a PersistenceManager", nameof(mapping));
            }

            Init(localMappings);
        }
Пример #12
0
 protected Class GetClassForTable(string tableName, NDOMapping mapping)
 {
     foreach (Class cl in mapping.Classes)
     {
         if (cl.TableName == tableName)
         {
             return(cl);
         }
     }
     return(null);
 }
Пример #13
0
        protected NDO.Mapping.Class FindClass(string tableName, NDOMapping mappings)
        {
            Class result = null;

            foreach (Class cl in mappings.Classes)
            {
                if (cl.TableName == tableName)
                {
                    result = cl;
                    break;
                }
            }
            return(result);
        }
Пример #14
0
        public void AssembyWideColumnAttributeOverwritesDefaultValues()
        {
            NDOMapping mapping = NDOMapping.Create(null);
            var        cls     = mapping.AddStandardClass("TestClass", "TestAssembly", null);

            Assert.AreEqual(1, cls.Oid.OidColumns.First().AutoIncrementStart);
            var attr = new OidColumnAttribute()
            {
                Name = "newColumnName", AutoIncrementStart = 2, IsAssemblyWideDefinition = true
            };

            cls.Oid.RemapOidColumns(new[] { attr });
            Assert.AreEqual(2, cls.Oid.OidColumns.First().AutoIncrementStart);
        }
Пример #15
0
        public void OidColumnShouldntBeRemappedWithAssembyWideColumnAttribute()
        {
            NDOMapping mapping = NDOMapping.Create(null);
            var        cls     = mapping.AddStandardClass("TestClass", "TestAssembly", null);

            Assert.AreEqual("ID", cls.Oid.OidColumns.First().Name);
            var attr = new OidColumnAttribute()
            {
                Name = "newColumnName", IsAssemblyWideDefinition = true
            };

            cls.Oid.RemapOidColumns(new[] { attr });
            Assert.AreEqual("ID", cls.Oid.OidColumns.First().Name);
        }
Пример #16
0
        public void RemapOidColumnsWorks()
        {
            NDOMapping mapping = NDOMapping.Create(null);
            var        cls     = mapping.AddStandardClass("TestClass", "TestAssembly", null);

            Assert.AreEqual("ID", cls.Oid.OidColumns.First().Name);
            var attr = new OidColumnAttribute()
            {
                Name = "newColumnName"
            };

            cls.Oid.RemapOidColumns(new[] { attr });
            Assert.AreEqual("newColumnName", cls.Oid.OidColumns.First().Name);
        }
Пример #17
0
        public void RemapForeignKeyColumnsWorks()
        {
            NDOMapping mapping = NDOMapping.Create(null);
            var        cls     = mapping.AddStandardClass("TestClass", "TestAssembly", null);

            mapping.AddStandardClass("RefTypeName", "TestAssembly", null);
            var relation = cls.AddStandardRelation("relField", "RefTypeName", false, "", false, false);

            Assert.AreEqual("IDTestClass", relation.ForeignKeyColumns.First().Name);
            var attr = new ForeignKeyColumnAttribute()
            {
                Name = "newColumnName"
            };

            relation.RemapForeignKeyColumns(new[] { attr }, new ChildForeignKeyColumnAttribute[] { });
            Assert.AreEqual("newColumnName", relation.ForeignKeyColumns.First().Name);
        }
Пример #18
0
        public void Generate(DataSet dsSchema, DataSet dsBak, string filename, NDOMapping mappings, MessageAdapter messages)
        {
            this.mappings = mappings;
            this.messages = messages;

            string   diffFileName  = filename.Replace(".ndo.sql", ".ndodiff." + mappings.SchemaVersion + ".xml");
            bool     isNewDiffFile = !File.Exists(diffFileName);
            XElement rootElement   = null;
            string   newSchema     = null;

            if (isNewDiffFile)
            {
                rootElement = new XElement("NdoSchemaTransitions");
                rootElement.Add(new XComment("NDO accumulates all schema changes in this diff file. Note: If you change the mapping schema version, a new diff file will be created. You can change the mapping schema version in the NDO configuration dialog. Don't use the Mapping Tool to change the schema information, because it will be overwritten by the value set in the configuration. For automatic builds set the schema version value in the .ndoproj file."));
                newSchema = mappings.SchemaVersion + ".1";
                rootElement.Add(new XAttribute("schemaVersion", newSchema));
            }
            else
            {
                rootElement = XElement.Load(diffFileName);
                string schemaVersion = rootElement.Attribute("schemaVersion").Value;
                int    p             = schemaVersion.LastIndexOf('.');
                int    v             = 1;
                int.TryParse(schemaVersion.Substring(p + 1), out v);
                if (p > -1)
                {
                    newSchema = mappings.SchemaVersion + "." + (v + 1);
                }
                else
                {
                    newSchema = mappings.SchemaVersion + ".1";
                }

                rootElement.Attribute("schemaVersion").Value = newSchema;
            }

            XElement transElement = new XElement("NdoSchemaTransition", new XAttribute("schemaVersion", newSchema));

            rootElement.Add(transElement);

            if (GenerateInternal(dsSchema, dsBak, transElement))
            {
                rootElement.Save(diffFileName);
            }
        }
Пример #19
0
        public void Load(string fileName)
        {
            this.fileName       = fileName;
            this.nodeCollection = new ArrayList();

            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);
            Assembly assembly = new Assembly(doc);

            this.assemblyNode = new AssemblyNode(assembly);
            this.mapping      = new NDO.Mapping.NDOMapping(fileName);
            NDO.Mapping.Connection conn = (NDO.Mapping.Connection)mapping.Connections[0];
            XmlElement             node = (XmlElement)doc.SelectSingleNode("NDOMapping/AssemblyElement");
            Database db = new Database(conn.Name, conn.Type, node.Attributes["DbOwner"].Value);

            this.databaseNode = new DatabaseNode(db);              // Loads all db related information
        }
Пример #20
0
        private Class GetParentClass(OqlExpression exp, string[] arr, out string fieldName, out Relation relation)
        {
            Class      relClass = this.cls;
            NDOMapping mappings = relClass.Parent;
            int        i;

            relation = null;

            for (i = 0; i < arr.Length - 1; i++)
            {
                relation = relClass.FindRelation(arr[i]);
                if (relation == null)                  // must be a value type or embedded type
                {
                    break;
                }

                if (this.queryContext.ContainsKey(relation))
                {
                    relClass = this.queryContext[relation];
                }
                else
                {
                    relClass = mappings.FindClass(relation.ReferencedType);
                }
            }

            fieldName = String.Join(".", arr, i, arr.Length - i);
            if (relClass.FindField(fieldName) == null && fieldName.IndexOf('.') > -1)
            {
                // We might have a value type or embedded type here.
                // These don't have accessor names.
                // So we try to find the field via the standard column name.
                // Note, that this doesn't work, if the column name was remapped.
                // But we don't see another solution for this situation.
                string tempName = fieldName.Replace('.', '_');
                var    field    = relClass.Fields.FirstOrDefault(f => f.Column.Name == tempName);
                if (field != null)
                {
                    fieldName = field.Name;
                }
            }

            return(relClass);
        }
Пример #21
0
        public void MappingTableAttributeWorks()
        {
            NDOMapping mapping  = NDOMapping.Create(null);
            var        cls      = mapping.AddStandardClass("TestClass", "TestAssembly", null);
            var        relation = cls.AddStandardRelation("relField", "RefTypeName", false, "", false, false);

            Assert.AreEqual("IDTestClass", relation.ForeignKeyColumns.First().Name);
            var attr = new MappingTableAttribute();

            relation.RemapMappingTable(false, false, attr);
            Assert.That(relation.MappingTable != null);
            Assert.AreEqual("relRefTypeNameTestClass", relation.MappingTable.TableName);
            Assert.AreEqual("IDTestClass", relation.ForeignKeyColumns.First().Name);
            Assert.AreEqual("IDRefTypeName", relation.MappingTable.ChildForeignKeyColumns.First().Name);

            attr.TableName = "newTableName";
            relation.RemapMappingTable(false, false, attr);
            Assert.AreEqual("newTableName", relation.MappingTable.TableName);
        }
Пример #22
0
        public static List <FieldEntry> GetFieldEntries(Type t, NDOMapping mapping)
        {
            List <FieldEntry> result = new List <FieldEntry>();
            Class             cl     = mapping.FindClass(t);

            if (cl == null)
            {
                throw new Exception("Class mapping for type " + t.FullName + " not found.");
            }
            foreach (Field f in cl.Fields)
            {
                FieldInfo fi = t.GetField(f.Name, BindingFlags.Instance | BindingFlags.NonPublic);
                if (fi != null && fi.FieldType != typeof(byte[]))
                {
                    result.Add(new FieldEntry(fi, f));
                }
            }
            return(result);
        }
Пример #23
0
        public ClassNode(Type t, NDOMapping mappings)
        {
            this.classType = t;
            if (t.IsGenericType && !t.IsGenericTypeDefinition)
            {
                throw new InternalException(45, "ClassNode");
            }
            this.mappings     = mappings;
            this.name         = new ReflectedType(t).ILNameWithoutPrefix;
            this.isInterface  = t.IsInterface;
            this.isPersistent = IsPersistentType(t);

            Type basetype = t.BaseType;

            this.baseFullName = new ReflectedType(basetype).ILNameWithoutPrefix;
            this.isAbstract   = t.IsAbstract;
            AnalyzeFields();
            CheckOidAttributes();
        }
Пример #24
0
 /// <summary>
 /// Used by the NDO Enhancer. Makes sure, that all classes of a certain mapping file
 /// are represented in the schema.
 /// </summary>
 /// <param name="mapping">A NDOMapping object.</param>
 public void Remap(NDOMapping mapping)
 {
     foreach (Class cl in mapping.Classes)
     {
         if (cl.IsAbstract)
         {
             continue;
         }
         new SchemaGenerator(cl, mapping, this).GenerateTables();
     }
     foreach (Class cl in mapping.Classes)
     {
         if (cl.IsAbstract)
         {
             continue;
         }
         new SchemaGenerator(cl, mapping, this).GenerateRelations();
     }
     this.EnforceConstraints = false;
 }
Пример #25
0
        public void GleicherKlassenName()
        {
            string     testFile            = "Text.Xml";
            string     newclassMitarbeiter = classMitarbeiter.Replace("Personal", "Test");
            NDOMapping mapping             = NDOMapping.Create(testFile);

            mapping.AddStandardClass(classMitarbeiter, assName, null);
            mapping.AddStandardClass(newclassMitarbeiter, assName, null);
            mapping.Save();
            mapping = new NDOMapping(testFile);

            Class c = mapping.FindClass(classMitarbeiter);

            Assert.NotNull(c, classMitarbeiter + " nicht gefunden");

            Class c2 = mapping.FindClass(newclassMitarbeiter);

            Assert.NotNull(c, newclassMitarbeiter + " nicht gefunden");

            Assert.That(c.TableName != c2.TableName, "TableNames mössen ungleich sein");
        }
Пример #26
0
        public void Anlegen1to1Relation()
        {
            string     testFile = "Test.Xml";
            NDOMapping mapping  = NDOMapping.Create(testFile);
            Class      c        = mapping.AddStandardClass(classMitarbeiter, assName, null);

            c.AddStandardRelation("dieReise", "Reise", true, "", false, false);
            mapping.Save();
            mapping = new NDOMapping(testFile);
            Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection");
            Assert.AreEqual(1, mapping.Classes.Count, "Keine Klasse");
            c = (Class)mapping.Classes[0];
            Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch");
            Assert.NotNull(c.Oid, "Keine Oid");
            Assert.AreEqual(1, c.Relations.Count, "Keine Relation");
            Relation r = (Relation)c.Relations[0];

            Assert.AreEqual("dieReise", r.FieldName, "FieldName falsch");
            Assert.AreEqual("1:1", r.GetRelationType(), "Relationstyp falsch");
            Assert.AreEqual("IDReise", ((ForeignKeyColumn)r.ForeignKeyColumns[0]).Name, "ForeignKeyColumnName falsch");
        }
Пример #27
0
        public void RelationTest()
        {
            NDOMapping mapping    = pm.NDOMapping;
            Class      reiseClass = mapping.FindClass(typeof(Reise));
            Class      pkwClass   = mapping.FindClass(typeof(PKWFahrt));

            Assert.NotNull(reiseClass, "Mapping for Reise not found");
            Assert.NotNull(pkwClass, "Mapping for pkw not found");
            Relation r1 = reiseClass.FindRelation("belege");

            Assert.NotNull(r1, "Relation not found #1");
            Assert.NotNull(r1.ForeignRelation, "ForeignRelation of Reise not found");
            Relation r2 = pkwClass.FindRelation("reise");

            Assert.NotNull(r2, "Relation not found #2");
            Assert.NotNull(r2.ForeignRelation, "ForeignRelation of PKWFahrt not found");
            Assert.That(r1 == r2.ForeignRelation, "Back relation wrong");
//			Debug.WriteLine(r1.Parent.FullName + "->" + r1.ReferencedTypeName);
//			Debug.WriteLine(r1.ForeignRelation.Parent.FullName + "->" + r1.ForeignRelation.ReferencedTypeName);
//			Debug.WriteLine(r2.Parent.FullName + "->" + r2.ReferencedTypeName);
//			Debug.WriteLine(r2.ForeignRelation.Parent.FullName + "->" + r2.ForeignRelation.ReferencedTypeName);
        }
Пример #28
0
        private void LoadMapping(string fileName)
        {
            allObjects.Nodes.Clear();
            try
            {
                mapping = new NDOMapping(fileName);
                PrepareRelations();
            }
            catch (Exception ex)
            {
                mapping   = null;
                this.Text = string.Empty;
#if DEBUG
                MessageBox.Show(ex.ToString(), "Error");
#else
                MessageBox.Show(ex.Message, "Error");
#endif
                return;
            }
            this.Text = fileName;
            FillNodes();
        }
Пример #29
0
        public void AnlegenKlasse()
        {
            NDOMapping mapping = NDOMapping.Create(testFile);

            mapping.AddStandardClass(classMitarbeiter, assName, null);
            mapping.Save();
            mapping = new NDOMapping(testFile);

            Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection");
            Assert.AreEqual(1, mapping.Classes.Count, "Keine Klasse");

            Class c = (Class)mapping.Classes[0];

            Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch");
            Assert.NotNull(c.Oid, "Keine Oid");
            Assert.AreEqual("C0", mapping.FindConnection(c).ID, "Connection C0 nicht gefunden");

            c = mapping.FindClass(classMitarbeiter);

            Assert.NotNull(c, "FindClass fehlgeschlagen");

            File.Delete(testFile);
        }
Пример #30
0
        public void AnlegenField()
        {
            string     testFile = "Test.Xml";
            NDOMapping mapping  = NDOMapping.Create(testFile);
            Class      c        = mapping.AddStandardClass(classMitarbeiter, assName, null);

            c.AddStandardField("vorname", false);
            mapping.Save();
            mapping = new NDOMapping(testFile);

            Assert.AreEqual(1, mapping.Connections.Count, "Keine Connection");
            Assert.AreEqual(1, mapping.Classes.Count, "Keine Klasse");

            c = (Class)mapping.Classes[0];

            Assert.AreEqual("Mitarbeiter", c.TableName, "TableName falsch");
            Assert.NotNull(c.Oid, "Keine Oid");
            Assert.AreEqual(1, c.Fields.Count, "Kein Field");

            Field f = (Field)c.Fields[0];

            Assert.AreEqual("Vorname", f.Column.Name, "ColumnName falsch");
        }