Beispiel #1
0
        public void Build_EntityWithTwoFields_Anchor()
        {
            var factory = new InfoFactory();
            var info = factory.Build("Student", new List<Tuple<string, string>>()
                    {
                        new Tuple<string, string>("LastName", "varchar(200)")
                        , new Tuple<string, string>("AvgScore", "decimal(6,3)")
                    }
            );

            Assert.IsInstanceOfType(info, typeof(Info));
            Assert.IsNotNull(info);
            Assert.AreEqual("StudentInfo", info.Shortname);

            Assert.AreEqual("LastName", info.Fields[0].Name);
            Assert.AreEqual(SqlDataType.VarChar, info.Fields[0].DataType.SqlDataType);
            Assert.AreEqual(200, info.Fields[0].DataType.Precision);

            Assert.AreEqual("AvgScore", info.Fields[1].Name);
            Assert.AreEqual(SqlDataType.Decimal, info.Fields[1].DataType.SqlDataType);
            Assert.AreEqual(6, info.Fields[1].DataType.Precision);
            Assert.AreEqual(3, info.Fields[1].DataType.Scale);

            Assert.AreEqual("StudentInfoId", info.Identity.Name);
            Assert.AreEqual(SqlDataType.Int, info.Identity.DataType.SqlDataType);
        }
Beispiel #2
0
        protected override IEnumerable<Table> OnBuild()
        {
            foreach (var entity in BluePrint.Entities)
            {
                var factory = new InfoFactory();
                if (entity.Attributes.Any(a => a.IsMultiValued))
                    throw new ArgumentException("Multivalued attributes are not supported at the moment.");

                var items = entity.Attributes.Where(a => a.IsPartOfPrimaryKey == false).Select(a => new ColumnFactory().Build(a.Label, a.DataType, a.IsNullable, false, a.DefaultFormula, a.DerivedFormula, a.IsSparse));
                var info = factory.Build(entity.Label, items);
                yield return info;
            }
        }