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


C# ClassMap類代碼示例

本文整理匯總了C#中ClassMap的典型用法代碼示例。如果您正苦於以下問題:C# ClassMap類的具體用法?C# ClassMap怎麽用?C# ClassMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified

        public void ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified()
        {
            var model = new PersistenceModel();
            var leftMap = new ClassMap<Left>();

            leftMap.Id(x => x.Id);
            leftMap.HasManyToMany(x => x.Rights);

            var rightMap = new ClassMap<Right>();

            rightMap.Id(x => x.Id);
            rightMap.HasManyToMany(x => x.Lefts)
                .Table("MyJoinTable");

            model.Add(leftMap);
            model.Add(rightMap);

            var mappings = model.BuildMappings();

            var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
            var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();

            leftMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
            rightMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
        }
開發者ID:nsreddy1986,項目名稱:fluent-nhibernate,代碼行數:25,代碼來源:ManyToManyTableNameTests.cs

示例2: CanCreateClassMap

        public void CanCreateClassMap()
        {
            var classMap = new ClassMap<Artist>();
            ClassMapping mapping = classMap.GetClassMapping();

            mapping.Type.ShouldEqual(typeof(Artist));
        }
開發者ID:paulbatum,項目名稱:Fluent-NHibernate-Semantic-Model-Rewrite,代碼行數:7,代碼來源:ClassMapTester.cs

示例3: SetUp

 public void SetUp()
 {
     tourMap = new ClassMap<Tour>(Version.LUCENE_30);
     tourMap.Property(p => p.AccommodationAges).Stored().NotAnalyzed();
     tourMap.Property(p => p.TotalPriceMin).Stored().NotAnalyzed();
     tourMap.Property(p => p.TotalPriceMax).Stored().NotAnalyzed();
 }
開發者ID:Zaixu,項目名稱:Lucene.Net.Linq,代碼行數:7,代碼來源:EnumerableContainsTests.cs

示例4: ShouldAllowConventionsToAlterBiDirectionalTableNames

        public void ShouldAllowConventionsToAlterBiDirectionalTableNames()
        {
            var model = new PersistenceModel();
            var leftMap = new ClassMap<Left>();

            leftMap.Id(x => x.Id);
            leftMap.HasManyToMany(x => x.Rights);

            var rightMap = new ClassMap<Right>();

            rightMap.Id(x => x.Id);
            rightMap.HasManyToMany(x => x.Lefts);

            model.Add(leftMap);
            model.Add(rightMap);
            model.Conventions.Add<TestTableNameConvention>();

            var mappings = model.BuildMappings();

            var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
            var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();

            leftMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
            rightMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
        }
開發者ID:heyitsanewb,項目名稱:PokeWorld-Online,代碼行數:25,代碼來源:ManyToManyTableNameTests.cs

示例5: GenerateIdsFor

        public void GenerateIdsFor(object entity, ClassMap classMap)
        {
            this.currentClassMap = classMap;
            this.currentEntity = entity;

            this.Visit(classMap);
        }
開發者ID:andoco,項目名稱:mongodb-csharp,代碼行數:7,代碼來源:IdGenerator.cs

示例6: Mapping

        private void Mapping(Action<KeyManyToOnePart> mappingDefinition)
        {
            var classMap = new ClassMap<ExampleClass>();
            var map = classMap.CompositeId()
                .KeyProperty(x => x.Id)
                .KeyReference(x => x.Parent, mappingDefinition);

            mapping = classMap;
        }
開發者ID:jjchoi,項目名稱:fluent-nhibernate,代碼行數:9,代碼來源:KeyManyToOneConventionTests.cs

示例7: CanMapProperty

        public void CanMapProperty()
        {
            var classMap = new ClassMap<Artist>();
            classMap.Map(x => x.Name);
            ClassMapping mapping = classMap.GetClassMapping();

            var property = mapping.Properties.FirstOrDefault();
            property.ShouldNotBeNull();
            property.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Artist>(x => x.Name));
        }
開發者ID:paulbatum,項目名稱:Fluent-NHibernate-Semantic-Model-Rewrite,代碼行數:10,代碼來源:ClassMapTester.cs

示例8: CanMapCollection

        public void CanMapCollection()
        {
            var classMap = new ClassMap<Artist>();
            classMap.HasMany<Album>(x => x.Albums);
            ClassMapping mapping = classMap.GetClassMapping();

            var collection = mapping.Collections.FirstOrDefault() as BagMapping;
            collection.ShouldNotBeNull();
            collection.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Artist>(x => x.Albums));
        }
開發者ID:paulbatum,項目名稱:Fluent-NHibernate-Semantic-Model-Rewrite,代碼行數:10,代碼來源:ClassMapTester.cs

示例9: CanMapReference

        public void CanMapReference()
        {
            var classMap = new ClassMap<Album>();
            classMap.References(x => x.Artist);
            ClassMapping mapping = classMap.GetClassMapping();

            var reference = mapping.References.FirstOrDefault();
            reference.ShouldNotBeNull();
            reference.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Album>(x => x.Artist));
        }
開發者ID:paulbatum,項目名稱:Fluent-NHibernate-Semantic-Model-Rewrite,代碼行數:10,代碼來源:ClassMapTester.cs

示例10: NeverShouldSetDefaultLazyToFalse

 public void NeverShouldSetDefaultLazyToFalse()
 {
     var classMap = new ClassMap<Target>();
     classMap.Id(x => x.Id);
     model.Add(classMap);
     model.Conventions.Add(DefaultLazy.Never());
     model.BuildMappings()
         .First()
         .DefaultLazy.ShouldBeFalse();
 }
開發者ID:garrisonx,項目名稱:NH3BegginnersGuide,代碼行數:10,代碼來源:DefaultLazyHelperTests.cs

示例11: ShouldSetDefaultAccessToValue

 public void ShouldSetDefaultAccessToValue()
 {
     var classMap = new ClassMap<Target>();
     classMap.Id(x => x.Id);
     model.Add(classMap);
     model.Conventions.Add(AutoImport.Never());
     model.BuildMappings()
         .First()
         .AutoImport.ShouldEqual(false);
 }
開發者ID:nsreddy1986,項目名稱:fluent-nhibernate,代碼行數:10,代碼來源:AutoImportHelperTests.cs

示例12: AlwaysShouldSetDefaultLazyToTrue

 public void AlwaysShouldSetDefaultLazyToTrue()
 {
     var classMap = new ClassMap<Target>();
     classMap.Id(x => x.Id);
     model.Add(classMap);
     model.Conventions.Add(DefaultLazy.Always());
     model.BuildMappings()
         .First()
         .DefaultLazy.ShouldBeTrue();
 }
開發者ID:garrisonx,項目名稱:NH3BegginnersGuide,代碼行數:10,代碼來源:DefaultLazyHelperTests.cs

示例13: ShouldSetDefaultAccessToValue

 public void ShouldSetDefaultAccessToValue()
 {
     var classMap = new ClassMap<Target>();
     classMap.Id(x => x.Id);
     model.Add(classMap);
     model.Conventions.Add(DefaultAccess.Field());
     model.BuildMappings()
         .First()
         .DefaultAccess.ShouldEqual("field");
 }
開發者ID:garrisonx,項目名稱:NH3BegginnersGuide,代碼行數:10,代碼來源:DefaultAccessHelperTests.cs

示例14: establish_context

        public override void establish_context()
        {
            inline_component = new ClassMap<Target>();
            inline_component.Component(x => x.ComponentProperty, c => c.Map(x => x.Property));

            external_component = new ComponentMap<Component>();
            external_component.Map(x => x.Property);

            reference_component = new ClassMap<Target>();
            reference_component.Component(x => x.ComponentProperty);
        }
開發者ID:JamesKovacs,項目名稱:fluent-nhibernate,代碼行數:11,代碼來源:ExternalComponentOutputSpecs.cs

示例15: CreateDocument

        public Document CreateDocument(ClassMap classMap, object entity)
        {
            if (entity == null)
                throw new ArgumentNullException("entity");
            this.entity = entity;

            this.document = new Document();
            classMap.Accept(this);

            return this.document;
        }
開發者ID:andoco,項目名稱:mongodb-csharp,代碼行數:11,代碼來源:DeleteDocumentMapper.cs


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