當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。