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


C# ClassMap.Id方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: Mapping

        private void Mapping(Action<ComponentPart<ComponentTarget>> mappingDefinition)
        {
            var classMap = new ClassMap<PropertyTarget>();
            classMap.Id(x => x.Id);
            var map = classMap.Component(x => x.Component, mappingDefinition);

            mappingDefinition(map);

            mapping = classMap;
            mappingType = typeof(PropertyTarget);
        }
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:11,代码来源:ComponentConventionTests.cs

示例8: VerifyModel

        private void VerifyModel(Action<HibernateMapping> modelVerification)
        {
            var classMap = new ClassMap<ExampleClass>();
            classMap.Id(x => x.Id);

            model.Add(classMap);

            var generatedModels = model.BuildMappings();
            var modelInstance = generatedModels
                .First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleClass)) != null);

            modelVerification(modelInstance);
        }
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:13,代码来源:HibernateMappingConventionTests.cs

示例9: AlwaysShouldSetDefaultLazyToTrue

        public void AlwaysShouldSetDefaultLazyToTrue()
        {
            var classMap = new ClassMap<Target>();
            classMap.Id(x => x.Id);
            model.Add(classMap);
            model.Conventions.Add(DefaultLazy.Always());
            model.Conventions.Add(DefaultCascade.All());
            
            var mapping = model.BuildMappings().First();

            mapping.DefaultLazy.ShouldBeTrue();
            mapping.DefaultCascade.ShouldEqual("all");
        }
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:13,代码来源:MultipleHelperConventions.cs

示例10: ShouldntDuplicateJoinMapping

        public void ShouldntDuplicateJoinMapping()
        {
            var model = new PersistenceModel();
            var classMap = new ClassMap<Target>();

            classMap.Id(x => x.Id);
            classMap.Join("other", m => m.Map(x => x.Property));

            model.Add(classMap);
            model.Configure(cfg);

            cfg.ClassMappings.First()
                .JoinClosureIterator.Count().ShouldEqual(1);
        }
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:14,代码来源:JoinPersistenceModelTests.cs

示例11: ShouldSetForeignKeyOnJoin

        public void ShouldSetForeignKeyOnJoin()
        {
            var classMap = new ClassMap<ExampleInheritedClass>();

            classMap.Id(x => x.Id);
            classMap.Join("two", m => { });

            model.Add(classMap);

            model.BuildMappings()
                .First()
                .Classes.First()
                .Joins.First()
                .Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
        }
开发者ID:AndyStewart,项目名称:fluent-nhibernate,代码行数:15,代码来源:ForeignKeyConventionTests.cs

示例12: establish_context

        public override void establish_context()
        {
            model = new PersistenceModel();

            var comp_map = new ComponentMap<ComponentTarget>();
            comp_map.Map(x => x.Property);

            model.Add(comp_map);

            var map = new ClassMap<Target>();
            map.Id(x => x.Id);
            map.Component(x => x.Component)
                .ColumnPrefix(column_prefix);
            model.Add(map);
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:15,代码来源:ComponentColumnPrefixVisitorSpecs.cs

示例13: ShouldSetForeignKeyOnManyToMany

        public void ShouldSetForeignKeyOnManyToMany()
        {
            var classMap = new ClassMap<ExampleInheritedClass>();

            classMap.Id(x => x.Id);
            classMap.HasManyToMany(x => x.Children);

            model.Add(classMap);

            model.BuildMappings()
                .First()
                .Classes.First()
                .Collections.First()
                .Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
        }
开发者ID:AndyStewart,项目名称:fluent-nhibernate,代码行数:15,代码来源:ForeignKeyConventionTests.cs

示例14: ShouldSetForeignKeyOnManyToOne

        public void ShouldSetForeignKeyOnManyToOne()
        {
            var classMap = new ClassMap<ExampleClass>();

            classMap.Id(x => x.Id);
            classMap.References(x => x.Parent);

            model.Add(classMap);

            model.BuildMappings()
                .First()
                .Classes.First()
                .References.First()
                .Columns.First().Name.ShouldEqual("Parent!");
        }
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:15,代码来源:ForeignKeyConventionTests.cs

示例15: ShouldAllowOverridingOfDefaultInConventions

        public void ShouldAllowOverridingOfDefaultInConventions()
        {
            var model = new PersistenceModel();

            var map = new ClassMap<IdentityExamples>();

            map.Id(x => x.Int);

            model.Conventions.Add(new IdConvention());
            model.Add(map);
            var @class = model.BuildMappings()
                .First()
                .Classes.First();

            ((IdMapping)@class.Id).Generator.Class.ShouldEqual("increment");
        }
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:16,代码来源:IdGeneratorTests.cs


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