Esempio n. 1
0
 public string GetSqlDataTypeDefinition()
 {
     if (blAttribute is CustomBLAttribute)
     {
         if (blAttribute.Name == "Mandant_KNZ")
         {
             return("int not null"); // Mandant_ID
         }
         else if (blAttribute.ParentInterface.InterfaceType == CoreInterfaceType.FACT_TABLE)
         {
             return("bigint primary key not null"); // *_ID Spalte in Faktentabelle
         }
         else if (blAttribute.IsIdentity)
         {
             return("int primary key not null"); // *_ID Spalte in Dimensionstabelle
         }
         else
         {
             throw new InvalidDataTypeException();
         }
     }
     else
     {
         return(blAttribute.GetSqlDataTypeDefinition());
     }
 }
Esempio n. 2
0
        private string GenerateAttribute(IBLAttribute attr, IBLInterface ifa)
        {
            string code = $"{attr.Name} {attr.GetSqlDataTypeDefinition()}";

            if (ifa.Attributes.Last() != attr)
            {
                code += ", ";
            }
            return(code);
        }
        public void TestCustomBLAttribute_Mandant_Sample2()
        {
            IBLAttribute attr = CustomBLAttribute.GetNewMandantAttribute(null);

            Assert.AreEqual("varchar(10) not null", attr.GetSqlDataTypeDefinition());
            Assert.AreEqual("Mandant_KNZ", attr.Name);
            Assert.AreEqual(10, attr.Length);
            Assert.AreEqual(0, attr.Decimals);
            Assert.AreEqual(CoreDataType.VARCHAR, attr.DataType);
            Assert.IsNull(attr.ParentInterface);
            Assert.IsTrue(attr.IsPartOfUniqueKey);
            Assert.IsFalse(attr.IsIdentity);
            Assert.IsFalse(attr.IsPrimaryKey);
        }
        public void TestCustomBLAttribute_TableID_Sample1()
        {
            IBLInterface parent = new BLInterfaceMock()
            {
                ShortName = "Semester"
            };

            IBLAttribute attr = CustomBLAttribute.GetNewIDAttribute(parent);

            Assert.AreEqual("Semester_ID", attr.Name);
            Assert.AreEqual(0, attr.Length);
            Assert.AreEqual(0, attr.Decimals);
            Assert.AreEqual(CoreDataType.INT, attr.DataType);
            Assert.AreEqual(parent, attr.ParentInterface);
            Assert.IsTrue(attr.IsIdentity);
            Assert.IsTrue(attr.IsPrimaryKey);
            Assert.AreEqual("int primary key identity not null", attr.GetSqlDataTypeDefinition());
        }
        public void TestCustomBLAttribute_TAendDat()
        {
            IBLInterface parent = new BLInterfaceMock()
            {
                ShortName = "Semester"
            };

            IBLAttribute attr = CustomBLAttribute.GetNewTAendDatAttribute(parent);

            Assert.AreEqual("T_Aend_Dat", attr.Name);
            StringAssert.EndsWith(attr.FullName, attr.Name);
            Assert.AreEqual(0, attr.Length);
            Assert.AreEqual(0, attr.Decimals);
            Assert.AreEqual(CoreDataType.DATETIME, attr.DataType);
            Assert.AreEqual(parent, attr.ParentInterface);
            Assert.IsFalse(attr.IsIdentity);
            Assert.IsFalse(attr.IsPrimaryKey);
            Assert.AreEqual("datetime not null", attr.GetSqlDataTypeDefinition());
        }
        public void TestCustomBLAttribute_TModifikation()
        {
            IBLInterface parent = new BLInterfaceMock()
            {
                ShortName = "Semester"
            };

            IBLAttribute attr = CustomBLAttribute.GetNewTModifikationAttribute(parent);

            Assert.AreEqual("T_Modifikation", attr.Name);
            StringAssert.EndsWith(attr.FullName, attr.Name);
            Assert.AreEqual(10, attr.Length);
            Assert.AreEqual(0, attr.Decimals);
            Assert.AreEqual(CoreDataType.VARCHAR, attr.DataType);
            Assert.AreEqual(parent, attr.ParentInterface);
            Assert.IsFalse(attr.IsIdentity);
            Assert.IsFalse(attr.IsPrimaryKey);
            Assert.IsFalse(attr.IsPartOfUniqueKey);
            Assert.AreEqual("varchar(10) not null", attr.GetSqlDataTypeDefinition());
        }
        public void TestCustomBLAttribute_TLadelaufNR()
        {
            IBLInterface parent = new BLInterfaceMock()
            {
                ShortName = "Semester"
            };

            IBLAttribute attr = CustomBLAttribute.GetNewTLadelaufNRAttribute(parent);

            Assert.AreEqual("T_Ladelauf_NR", attr.Name);
            StringAssert.EndsWith(attr.FullName, attr.Name);
            Assert.AreEqual(0, attr.Length);
            Assert.AreEqual(0, attr.Decimals);
            Assert.AreEqual(CoreDataType.INT, attr.DataType);
            Assert.AreEqual(parent, attr.ParentInterface);
            Assert.IsFalse(attr.IsIdentity);
            Assert.IsFalse(attr.IsPrimaryKey);
            Assert.IsFalse(attr.IsPartOfUniqueKey);
            Assert.AreEqual("int not null", attr.GetSqlDataTypeDefinition());
        }