当前位置: 首页>>代码示例>>C#>>正文


C# ActiveRecordModelBuilder.Create方法代码示例

本文整理汇总了C#中ActiveRecordModelBuilder.Create方法的典型用法代码示例。如果您正苦于以下问题:C# ActiveRecordModelBuilder.Create方法的具体用法?C# ActiveRecordModelBuilder.Create怎么用?C# ActiveRecordModelBuilder.Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveRecordModelBuilder的用法示例。


在下文中一共展示了ActiveRecordModelBuilder.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportsGeneration

        public void ImportsGeneration()
        {
            ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
            ActiveRecordModel model = builder.Create(typeof(ImportClass));
            Assert.IsNotNull(model);

            string xml = Process(builder, model);

            string expected =
                "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
                    "<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
                    "  <import class=\"Castle.ActiveRecord.Framework.Internal.Tests.ImportClassRow, Castle.ActiveRecord.Framework.Internal.Tests\" rename=\"ImportClassRow\" />\r\n" +
                    "  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ImportClass, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"ImportClass\" lazy=\"false\">\r\n" +
                    "    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
                    "      <generator class=\"native\">\r\n" +
                    "      </generator>\r\n" +
                    "    </id>\r\n" +
                    "    <property name=\"Name\" access=\"property\" type=\"String\">\r\n" +
                    "      <column name=\"Name\" />\r\n" +
                    "    </property>\r\n" +
                    "  </class>\r\n" +
                    "</hibernate-mapping>\r\n";

            Assert.AreEqual(expected, xml);
        }
开发者ID:zhoufoxcn,项目名称:ActiveRecord,代码行数:25,代码来源:ImportTestCase.cs

示例2: AnyAttribute

        public void AnyAttribute()
        {
            ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
            ActiveRecordModel model = builder.Create(typeof(ClassWithAnyAttribute));
            Assert.IsNotNull(model);

            SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(builder.Models);
            semanticVisitor.VisitNode(model);

            XmlGenerationVisitor xmlVisitor = new XmlGenerationVisitor();
            xmlVisitor.CreateXml(model);

            String xml = xmlVisitor.Xml;

            const string expected =
                "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
                "<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
                "  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassWithAnyAttribute, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"ClassWithAnyAttribute\">\r\n" +
                "    <id name=\"Id\" access=\"nosetter.camelcase-underscore\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
                "      <generator class=\"native\">\r\n" +
                "      </generator>\r\n" +
                "    </id>\r\n" +
                "    <any name=\"PaymentMethod\" access=\"property\" id-type=\"Int64\" meta-type=\"System.String\" cascade=\"save-update\" not-null=\"true\">\r\n" +
                "      <meta-value value=\"BANK_ACCOUNT\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.BankAccount, Castle.ActiveRecord.Framework.Internal.Tests\" />\r\n" +
                "      <column name=\"BILLING_DETAILS_TYPE\" />\r\n" +
                "      <column name=\"BILLING_DETAILS_ID\" />\r\n" +
                "    </any>\r\n" +
                "  </class>\r\n" +
                "</hibernate-mapping>\r\n";

            Assert.AreEqual(expected, xml);
        }
开发者ID:zhoufoxcn,项目名称:ActiveRecord,代码行数:32,代码来源:XmlGenerationTestCase.cs

示例3: SimpleCaseWithNestedComponent

		public void SimpleCaseWithNestedComponent()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(SimpleNestedComponent));
			Assert.IsNotNull(model);

			SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(builder.Models);
			semanticVisitor.VisitNode(model);

			XmlGenerationVisitor xmlVisitor = new XmlGenerationVisitor();
			xmlVisitor.CreateXml(model);

			String xml = xmlVisitor.Xml;

			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.SimpleNestedComponent, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"SimpleNestedComponent\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <component name=\"Nested\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.NestedComponent, Castle.ActiveRecord.Framework.Internal.Tests\" access=\"property\">\r\n" +
				"      <parent name=\"Parent\"/>\r\n" +
				"      <property name=\"NestedProperty\" access=\"property\" type=\"String\">\r\n" +
				"        <column name=\"NestedProperty\"/>\r\n" +
				"      </property>\r\n" +
				"    </component>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:33,代码来源:XmlGenerationTestCase.cs

示例4: UsingAnyWithoutSpecifyingTheMetaType

		public void UsingAnyWithoutSpecifyingTheMetaType()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(BadClassWithAnyAttribute));
			Assert.IsNotNull(model);

			Assert.IsNotNull(model);

			SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(builder.Models);
			semanticVisitor.VisitNode(model);
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:11,代码来源:SemanticCheckTestCase.cs

示例5: SimpleClassWithGuessedEnumElementList

		public void SimpleClassWithGuessedEnumElementList()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(EnumModel));
			Assert.IsNotNull(model);

			String xml = Process(builder, model);
			const string expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
									"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
									"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.EnumModel, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"EnumModel\">\r\n" +
									"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
									"      <generator class=\"native\">\r\n" +
									"      </generator>\r\n" +
									"    </id>\r\n" +
									"    <bag name=\"Roles\" access=\"property\" table=\"Roles\" lazy=\"false\">\r\n" +
									"      <key column=\"EnumModelId\" />\r\n" +
									"      <element  column=\"RoleId\"  type=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.Role, Castle.ActiveRecord.Framework.Internal.Tests\"/>\r\n" +
									"    </bag>\r\n" +
									"  </class>\r\n" +
									"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:23,代码来源:XmlGenerationTestCase.cs

示例6: CompositeClassWithBelongsTo

		public void CompositeClassWithBelongsTo()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(ClassWithCompositeKey3));
			Assert.IsNotNull(model);

			String xml = Process(builder, model);
			const string expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
									"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
									"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassWithCompositeKey3, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"ClassWithCompositeKey3\" lazy=\"false\">\r\n" +
									"    <composite-id name=\"Key\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.CompositeKey2, Castle.ActiveRecord.Framework.Internal.Tests\" unsaved-value=\"none\" access=\"property\">\r\n" +
									"      <key-property name=\"Key1\" access=\"property\" column=\"Key1\" type=\"Int32\" />\r\n" +
									"      <key-many-to-one name=\"Key2\" access=\"property\" column=\"Key2\" type=\"String\" />\r\n" +
									"    </composite-id>\r\n" +
									"  </class>\r\n" +
									"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:19,代码来源:XmlGenerationTestCase.cs

示例7: SimpleClassWithMappedFieldAndNonDefaultAccess

		public void SimpleClassWithMappedFieldAndNonDefaultAccess()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(ClassWithMappedField));
			Assert.IsNotNull(model);

			SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(builder.Models);
			semanticVisitor.VisitNode(model);

			XmlGenerationVisitor xmlVisitor = new XmlGenerationVisitor();
			xmlVisitor.CreateXml(model);

			String xml = xmlVisitor.Xml;

			const string expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
									"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
									"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassWithMappedField, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"ClassWithMappedField\">\r\n" +
									"    <id name=\"Id\" access=\"nosetter.camelcase-underscore\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
									"      <generator class=\"native\">\r\n" +
									"      </generator>\r\n" +
									"    </id>\r\n" +
									"    <property name=\"name1\" access=\"field\" type=\"String\">\r\n" +
									"      <column name=\"MyCustomName\"/>\r\n" +
									"    </property>\r\n" +
									"    <property name=\"Value\" access=\"CustomAccess\" type=\"Int32\">\r\n" +
									"      <column name=\"Value\"/>\r\n" +
									"    </property>\r\n" +
									"  </class>\r\n" +
									"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:32,代码来源:XmlGenerationTestCase.cs

示例8: HasManyToAnyAttribute

		public void HasManyToAnyAttribute()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(ClasssWithHasManyToAny));
			Assert.IsNotNull(model);

			SemanticVerifierVisitor semanticVisitor = new SemanticVerifierVisitor(builder.Models);
			semanticVisitor.VisitNode(model);

			XmlGenerationVisitor xmlVisitor = new XmlGenerationVisitor();
			xmlVisitor.CreateXml(model);

			String xml = xmlVisitor.Xml;
			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClasssWithHasManyToAny, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"ClasssWithHasManyToAny\">\r\n" +
				"    <id name=\"Id\" access=\"nosetter.camelcase-underscore\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <set name=\"PaymentMethod\" access=\"property\" table=\"payments_table\" lazy=\"false\">\r\n" +
				"      <key column=\"pay_id\" />\r\n" +
				"      <many-to-any id-type=\"Int32\" meta-type=\"Int32\">\r\n" +
				"        <column name=\"payment_type\" />\r\n" +
				"        <column name=\"payment_method_id\" />\r\n" +
				"      </many-to-any>\r\n" +
				"    </set>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:33,代码来源:XmlGenerationTestCase.cs

示例9: HasManyWithBatch

		public void HasManyWithBatch()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(HasManyWithBatch));
			Assert.IsNotNull(model);

			String xml = Process(builder, model);

			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.HasManyWithBatch, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"HasManyWithBatch\" lazy=\"false\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <bag name=\"Items\" access=\"property\" table=\"ClassATable\" lazy=\"false\" inverse=\"true\" batch-size=\"3\">\r\n" +
				"      <key column=\"keycol\" />\r\n" +
				"      <one-to-many class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassA, Castle.ActiveRecord.Framework.Internal.Tests\" />\r\n" +
				"    </bag>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:25,代码来源:XmlGenerationTestCase.cs

示例10: JoinedSubClassUseWithGenericTypeAndGenericAbstractBase

		public void JoinedSubClassUseWithGenericTypeAndGenericAbstractBase()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			builder.Create(typeof(GenSubClassJoinedClass));
			ActiveRecordModel model = builder.Create(typeof(GenBaseJoinedClass<GenSubClassJoinedClass>));
			Assert.IsNotNull(model);

			String xml = Process(builder, model);

			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.GenBaseJoinedClass`1[[Castle.ActiveRecord.Framework.Internal.Tests.Model.GenSubClassJoinedClass, Castle.ActiveRecord.Framework.Internal.Tests, Version=1.0.3.0, Culture=neutral, PublicKeyToken=null]], Castle.ActiveRecord.Framework.Internal.Tests\" table=\"disctable\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <property name=\"Name\" access=\"property\" type=\"String\">\r\n" +
				"      <column name=\"Name\"/>\r\n" +
				"    </property>\r\n" +
				"    <joined-subclass name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.GenSubClassJoinedClass, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"disctablea\" lazy=\"false\">\r\n" +
				"      <key column=\"AId\" />\r\n" +
				"      <property name=\"Age\" access=\"property\" type=\"Int32\">\r\n" +
				"        <column name=\"Age\"/>\r\n" +
				"      </property>\r\n" +
				"    </joined-subclass>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:31,代码来源:XmlGenerationTestCase.cs

示例11: ManyToMayViaComponents

		public void ManyToMayViaComponents()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(HasManyToManyViaComponents));
			Assert.IsNotNull(model);

			String xml = Process(builder, model);
			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.HasManyToManyViaComponents, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"HasManyToManyViaComponents\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <list name=\"Components\" access=\"property\" table=\"components_to_a\" lazy=\"false\">\r\n" +
				"      <key column=\"id\" />\r\n" +
				"      <index column=\"pos\" />\r\n" +
				"      <composite-element class=\"Castle.ActiveRecord.Framework.Internal.Tests.ComponentManyToClassA, Castle.ActiveRecord.Framework.Internal.Tests\">\r\n" +
				"        <property name=\"Value\" access=\"property\" type=\"String\">\r\n" +
				"          <column name=\"Value\"/>\r\n" +
				"        </property>\r\n" +
				"        <many-to-one name=\"A\" access=\"property\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassA, Castle.ActiveRecord.Framework.Internal.Tests\" column=\"aId\" />\r\n" +
				"      </composite-element>\r\n" +
				"    </list>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";
			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:29,代码来源:XmlGenerationTestCase.cs

示例12: HasManyWithDictionary

		public void HasManyWithDictionary()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel model = builder.Create(typeof(DictionaryModel));
			Assert.IsNotNull(model);

			string xml = Process(builder, model);

			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.DictionaryModel, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"DictionaryModel\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <map name=\"Snippet\" access=\"property\" table=\"DictionaryModel_Snippet\" lazy=\"false\">\r\n" +
				"      <key column=\"id\" />\r\n" +
				"      <index column=\"LangCode\" type=\"String\" />\r\n" +
				"      <element  column=\"Text\"  type=\"System.String, mscorlib\"/>\r\n" +
				"    </map>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:26,代码来源:XmlGenerationTestCase.cs

示例13: NotFoundBehaviourClass

		public void NotFoundBehaviourClass()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel NotFoundBehaviourClassModel = builder.Create(typeof(NotFoundBehaviourClass));
			ActiveRecordModel RelationalFoobarModel = builder.Create(typeof(RelationalFoobar));
			Assert.IsNotNull(NotFoundBehaviourClassModel);
			Assert.IsNotNull(RelationalFoobarModel);

			String xml = Process(builder, NotFoundBehaviourClassModel);

			string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.NotFoundBehaviourClass, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"NotFoundBehaviourClass\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <bag name=\"SubClasses\" access=\"property\" table=\"RelationalFoobarTable\" lazy=\"false\">\r\n" +
				"      <key column=\"keycol\" />\r\n" +
				"      <one-to-many class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.RelationalFoobar, Castle.ActiveRecord.Framework.Internal.Tests\" not-found=\"ignore\" />\r\n" +
				"    </bag>\r\n" +
				"    <bag name=\"ManySubClasses\" access=\"property\" table=\"ManySubClasses\" lazy=\"false\">\r\n" +
				"      <key column=\"id\" />\r\n" +
				"      <many-to-many class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.RelationalFoobar, Castle.ActiveRecord.Framework.Internal.Tests\" column=\"ref_id\" not-found=\"ignore\"/>\r\n" +
				"    </bag>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);

			xml = Process(builder, RelationalFoobarModel);

			expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.RelationalFoobar, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"RelationalFoobar\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <many-to-one name=\"NotFoundBehaviourClass\" access=\"property\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.NotFoundBehaviourClass, Castle.ActiveRecord.Framework.Internal.Tests\" column=\"NotFoundBehaviourClass\" not-found=\"ignore\" />\r\n" +
				"    <bag name=\"NotFoundBehaviourClassList\" access=\"property\" table=\"ManySubClasses\" lazy=\"false\">\r\n" +
				"      <key column=\"id\" />\r\n" +
				"      <many-to-many class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.NotFoundBehaviourClass, Castle.ActiveRecord.Framework.Internal.Tests\" column=\"ref_id\" not-found=\"ignore\"/>\r\n" +
				"    </bag>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:51,代码来源:XmlGenerationTestCase.cs

示例14: One2OneKey

		public void One2OneKey()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			ActiveRecordModel empModel = builder.Create(typeof(Employee));
			ActiveRecordModel awardModel = builder.Create(typeof(Award));
			Assert.IsNotNull(empModel);
			Assert.IsNotNull(awardModel);

			string xml = Process(builder, empModel);

			string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.Employee, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"Employee\" lazy=\"false\">\r\n" +
				"    <id name=\"ID\" access=\"property\" column=\"EmployeeID\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <property name=\"FirstName\" access=\"property\" type=\"String\">\r\n" +
				"      <column name=\"FirstName\"/>\r\n" +
				"    </property>\r\n" +
				"    <property name=\"LastName\" access=\"property\" type=\"String\">\r\n" +
				"      <column name=\"LastName\"/>\r\n" +
				"    </property>\r\n" +
				"    <one-to-one name=\"Award\" access=\"property\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.Award, Castle.ActiveRecord.Framework.Internal.Tests\" foreign-key=\"FK_FOREIGN_KEY\" fetch=\"join\" constrained=\"true\" />\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);

			xml = Process(builder, awardModel);

			expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.Award, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"Award\" lazy=\"false\">\r\n" +
				"    <id name=\"ID\" access=\"property\" column=\"EmployeeID\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"foreign\">\r\n" +
				"        <param name=\"property\">Employee</param>\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <property name=\"Description\" access=\"property\" type=\"String\">\r\n" +
				"      <column name=\"Description\"/>\r\n" +
				"    </property>\r\n" +
				"    <one-to-one name=\"Employee\" access=\"property\" class=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.Employee, Castle.ActiveRecord.Framework.Internal.Tests\" />\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:50,代码来源:XmlGenerationTestCase.cs

示例15: DiscriminatorLengthUse

		public void DiscriminatorLengthUse()
		{
			ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
			builder.Create(typeof(ClassDiscriminatorB));
			ActiveRecordModel model = builder.Create(typeof(ClassDiscriminatorLengthParent));
			Assert.IsNotNull(model);

			String xml = Process(builder, model);

			const string expected =
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
				"<hibernate-mapping  auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
				"  <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassDiscriminatorLengthParent, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"disctable\" discriminator-value=\"parent\">\r\n" +
				"    <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
				"      <generator class=\"native\">\r\n" +
				"      </generator>\r\n" +
				"    </id>\r\n" +
				"    <discriminator column=\"type\" type=\"String\" length=\"10\" />\r\n" +
				"    <property name=\"Name\" access=\"property\" type=\"String\">\r\n" +
				"      <column name=\"Name\"/>\r\n" +
				"    </property>\r\n" +
				"    <subclass name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ClassDiscriminatorB, Castle.ActiveRecord.Framework.Internal.Tests\" discriminator-value=\"B\">\r\n" +
				"      <property name=\"Age\" access=\"property\" type=\"Int32\">\r\n" +
				"        <column name=\"Age\"/>\r\n" +
				"      </property>\r\n" +
				"    </subclass>\r\n" +
				"  </class>\r\n" +
				"</hibernate-mapping>\r\n";

			Assert.AreEqual(expected, xml);
		}
开发者ID:ralescano,项目名称:castle,代码行数:31,代码来源:XmlGenerationTestCase.cs


注:本文中的ActiveRecordModelBuilder.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。