コード例 #1
0
ファイル: TphTest.cs プロジェクト: kjbartel/efmappingapi
        public void Contract_Contract()
        {
            using (var ctx = new TestContext())
            {
                var map = ctx.Db<Contract>();

                var columns = map.Properties;
                Assert.AreEqual(19, columns.Length);

                map.Prop(x => x.Id)
                    .IsIdentity()
                    .IsFk(false)
                    .IsDiscriminator(false)
                    .IsRequired()
                    .HasColumnName("Id");

                map.Prop(x => x.AvpContractNr)
                    .IsIdentity(false)
                    .IsFk(false)
                    .IsDiscriminator(false)
                    .IsRequired(false)
                    .HasColumnName("AvpContractNr")
                    .MaxLength(50);
            }
        }
コード例 #2
0
ファイル: TphTest.cs プロジェクト: kjbartel/efmappingapi
        public void Contract_ContractFixed()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = ctx.Db<ContractFixed>();

                var columns = tableMapping.Properties;
                Assert.AreEqual(21, columns.Length);
            }
        }
コード例 #3
0
ファイル: TphTest.cs プロジェクト: kjbartel/efmappingapi
        public void Contract_ContractBase()
        {
            using (var ctx = new TestContext())
            {
                var map = ctx.Db<ContractBase>();

                var columns = map.Properties;
                Assert.AreEqual(19, columns.Length);

                Assert.AreEqual(1, map.Discriminators.Length);
            }
        }
コード例 #4
0
ファイル: MappingTest.cs プロジェクト: kjbartel/efmappingapi
        public void Entity_ComplextType_WhereComplexTypeIsLastProperty()
        {
            using (var ctx = new TestContext())
            {
                var map = ctx.Db<House>();

                map.Prop(x => x.Name)
                    .HasColumnName("Name");

                map.Prop(x => x.Address.City)
                    .HasColumnName("Address_City");
            }
        }
コード例 #5
0
ファイル: TphTest.cs プロジェクト: kjbartel/efmappingapi
        public void Contract_ContractKomb1()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = ctx.Db<ContractKomb1>();

                var columns = tableMapping.Properties;
                Assert.AreEqual(24, columns.Length);

                tableMapping.Prop(x => x.Base)
                    .HasColumnName("Base")
                    .HasPrecision(18)
                    .HasScale(4);
            }
        }
コード例 #6
0
ファイル: MappingTest.cs プロジェクト: kjbartel/efmappingapi
        public void Entity_ComplexType()
        {
            using (var ctx = new TestContext())
            {
                var map = ctx.Db<TestUser>();

                map.Prop(x => x.Id)
                    .HasColumnName("Id")
                    .IsPk()
                    .IsFk(false)
                    .IsNavigationProperty(false);

                map.Prop(x => x.FirstName)
                    .HasColumnName("Name")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.LastName)
                    .HasColumnName("LastName")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.Contact.PhoneNumber)
                    .HasColumnName("Contact_PhoneNumber")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.Contact.Address.Country)
                    .HasColumnName("Contact_Address_Country")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.Contact.Address.County)
                    .HasColumnName("Contact_Address_County")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.Contact.Address.City)
                    .HasColumnName("Contact_Address_City")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.Contact.Address.PostalCode)
                    .HasColumnName("Contact_Address_PostalCode")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.Contact.Address.StreetAddress)
                    .HasColumnName("Contact_Address_StreetAddress")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);
            #if !NET40
                var propertyPropertyMap = map.Prop(x => x.Contact.Address.Location);
                propertyPropertyMap
                    .HasColumnName("Contact_Address_Location")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false);

                Console.WriteLine(propertyPropertyMap.DefaultValue);
                Console.WriteLine(propertyPropertyMap.FixedLength);
                Console.WriteLine(propertyPropertyMap.MaxLength);
                Console.WriteLine(propertyPropertyMap.Precision);
                Console.WriteLine(propertyPropertyMap.Scale);
                Console.WriteLine(propertyPropertyMap.Type);
                Console.WriteLine(propertyPropertyMap.Unicode);

                var shapePropertyMap = map.Prop(x => x.Contact.Address.Shape);
                shapePropertyMap
                    .HasColumnName("Contact_Address_Shape")
                    .IsPk(false)
                    .IsFk(false)
                    .IsNavigationProperty(false);

                Console.WriteLine(shapePropertyMap.DefaultValue);
                Console.WriteLine(shapePropertyMap.FixedLength);
                Console.WriteLine(shapePropertyMap.MaxLength);
                Console.WriteLine(shapePropertyMap.Precision);
                Console.WriteLine(shapePropertyMap.Scale);
                Console.WriteLine(shapePropertyMap.Type);
                Console.WriteLine(shapePropertyMap.Unicode);
            #endif
            }
        }
コード例 #7
0
ファイル: MappingTest.cs プロジェクト: kjbartel/efmappingapi
        public void Entity_Simple()
        {
            using (var ctx = new TestContext())
            {
                var map = ctx.Db<Page>();
                Console.WriteLine("{0}:{1}", map.Type, map.TableName);

                map.Prop(x => x.PageId)
                    .HasColumnName("PageId")
                    .IsPk()
                    .IsFk(false)
                    .IsIdentity()
                    .IsNavigationProperty(false);

                map.Prop(x => x.Title)
                    .HasColumnName("Title")
                    .IsPk(false)
                    .IsFk(false)
                    .IsIdentity(false)
                    .IsRequired()
                    .IsNavigationProperty(false)
                    .MaxLength(255);

                map.Prop(x => x.Content)
                    .HasColumnName("Content")
                    .IsPk(false)
                    .IsFk(false)
                    .IsIdentity(false)
                    .IsRequired(false)
                    .IsNavigationProperty(false)
                    .MaxLength(NvarcharMax);

                map.Prop(x => x.ParentId)
                    .HasColumnName("ParentId")
                    .IsPk(false)
                    .IsFk()
                    .IsIdentity(false)
                    .IsRequired(false)
                    .IsNavigationProperty(false)
                    .NavigationPropertyName("Parent");

                Assert.AreEqual(map.Prop(x => x.PageId), map.Prop(x => x.ParentId).FkTargetColumn);

                map.Prop(x => x.Parent)
                    .HasColumnName("ParentId")
                    .IsPk(false)
                    .IsFk(false)
                    .IsIdentity(false)
                    .IsNavigationProperty()
                    .ForeignKeyPropertyName("ParentId")
                    .ForeignKey(map.Prop(x => x.ParentId));

                map.Prop(x => x.CreatedAt)
                    .HasColumnName("CreatedAt")
                    .IsPk(false)
                    .IsFk(false)
                    .IsIdentity(false)
                    .IsRequired(true)
                    .IsNavigationProperty(false);

                map.Prop(x => x.ModifiedAt)
                    .HasColumnName("ModifiedAt")
                    .IsPk(false)
                    .IsFk(false)
                    .IsRequired(false)
                    .IsIdentity(false)
                    .IsNavigationProperty(false);
            }
        }