當前位置: 首頁>>代碼示例>>C#>>正文


C# TestContext.Db方法代碼示例

本文整理匯總了C#中NUnit.Framework.TestContext.Db方法的典型用法代碼示例。如果您正苦於以下問題:C# TestContext.Db方法的具體用法?C# TestContext.Db怎麽用?C# TestContext.Db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NUnit.Framework.TestContext的用法示例。


在下文中一共展示了TestContext.Db方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Contract_Contract

        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);
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:25,代碼來源:TphTest.cs

示例2: Contract_ContractFixed

        public void Contract_ContractFixed()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = ctx.Db<ContractFixed>();

                var columns = tableMapping.Properties;
                Assert.AreEqual(21, columns.Length);
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:10,代碼來源:TphTest.cs

示例3: Contract_ContractBase

        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);
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:12,代碼來源:TphTest.cs

示例4: Entity_ComplextType_WhereComplexTypeIsLastProperty

        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");
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:13,代碼來源:MappingTest.cs

示例5: Contract_ContractKomb1

        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);
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:15,代碼來源:TphTest.cs

示例6: Entity_ComplexType

        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
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:100,代碼來源:MappingTest.cs

示例7: Entity_Simple

        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);
            }
        }
開發者ID:kjbartel,項目名稱:efmappingapi,代碼行數:69,代碼來源:MappingTest.cs


注:本文中的NUnit.Framework.TestContext.Db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。