• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MappingSchema.HbmId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NHibernate.Cfg.MappingSchema.HbmId的典型用法代码示例。如果您正苦于以下问题:C# HbmId类的具体用法?C# HbmId怎么用?C# HbmId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HbmId类属于NHibernate.Cfg.MappingSchema命名空间,在下文中一共展示了HbmId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CanSetUnsavedValue

 public void CanSetUnsavedValue()
 {
     var hbmId = new HbmId();
     var mapper = new IdMapper(null, hbmId);
     mapper.UnsavedValue(-1);
     hbmId.unsavedvalue.Should().Be("-1");
 }
开发者ID:PedroAlvarado,项目名称:nhibernate-core,代码行数:7,代码来源:FixtureByCode.cs


示例2: CanSetColumnName

 public void CanSetColumnName()
 {
     var hbmId = new HbmId();
     var mapper = new IdMapper(null, hbmId);
     mapper.Column("MyName");
     hbmId.Columns.Single().name.Should().Be("MyName");
 }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:7,代码来源:IdMapperTest.cs


示例3: CreateIdentifierProperty

		private void CreateIdentifierProperty(HbmId idSchema, PersistentClass rootClass, SimpleValue id)
		{
			if (idSchema.name != null)
			{
				string access = idSchema.access ?? mappings.DefaultAccess;
				id.SetTypeUsingReflection(rootClass.MappedClass.AssemblyQualifiedName, idSchema.name, access);

				Mapping.Property property = new Mapping.Property(id);
				property.Name = idSchema.name;

				if (property.Value.Type == null)
					throw new MappingException("could not determine a property type for: " + property.Name);

				property.PropertyAccessorName = idSchema.access ?? mappings.DefaultAccess;
				property.Cascade = mappings.DefaultCascade;
				property.IsUpdateable = true;
				property.IsInsertable = true;
				property.IsOptimisticLocked = true;
				property.Generation = PropertyGeneration.Never;
				property.MetaAttributes = GetMetas(idSchema);

				rootClass.IdentifierProperty = property;

				LogMappedProperty(property);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:26,代码来源:ClassIdBinder.cs


示例4: BindId

		public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
		{
			if (idSchema != null)
			{
				var id = new SimpleValue(table);
				new TypeBinder(id, Mappings).Bind(idSchema.Type);

				rootClass.Identifier = id;

				Func<HbmColumn> defaultColumn = () => new HbmColumn
				{
					name = idSchema.name ?? RootClass.DefaultIdentifierColumnName,
					length = idSchema.length
				};

				new ColumnsBinder(id, Mappings).Bind(idSchema.Columns, false, defaultColumn);

				CreateIdentifierProperty(idSchema, rootClass, id);
				VerifiyIdTypeIsValid(id.Type, rootClass.EntityName);

				new IdGeneratorBinder(Mappings).BindGenerator(id, GetIdGenerator(idSchema));

				id.Table.SetIdentifierValue(id);

				BindUnsavedValue(idSchema, id);
			}
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:27,代码来源:ClassIdBinder.cs


示例5: CanSetGeneratorForeign

		public void CanSetGeneratorForeign()
		{
			var hbmId = new HbmId();
			new IdMapper(hbmId).Generator(Generators.Foreign<MyClass>(mc => mc.OneToOne));
			[email protected]().Be.EqualTo("foreign");
			hbmId.generator.param.Should().Not.Be.Null().And.Have.Count.EqualTo(1);
			hbmId.generator.param.Single().Satisfy(p => p.name == "property" && p.GetText() == "OneToOne");
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:8,代码来源:IdMapperTest.cs


示例6: CreateIdentifier

		private static SimpleValue CreateIdentifier(HbmId idSchema, PersistentClass rootClass, Table table)
		{
			SimpleValue iv = new SimpleValue(table);
			iv.TypeName = idSchema.type;
			rootClass.Identifier = iv;

			return iv;
		}
开发者ID:pallmall,项目名称:WCell,代码行数:8,代码来源:ClassIdBinder.cs


示例7: Should_get_null_given_column_is_null

 public void Should_get_null_given_column_is_null()
 {
     HbmId id = new HbmId
         {
             column = null
         };
     bool? result = id.CanBeNull();
     result.ShouldBeNull();
 }
开发者ID:MelleKoning,项目名称:hbm-to-fnh,代码行数:9,代码来源:HbmIdExtensionsTests.cs


示例8: CanSetGeneratorWithParameters

		public void CanSetGeneratorWithParameters()
		{
			var hbmId = new HbmId();
			new IdMapper(hbmId).Generator(Generators.HighLow, p => p.Params(new { max_low = 99, where = "TableName" }));
			[email protected]().Be.EqualTo("hilo");
			hbmId.generator.param.Should().Have.Count.EqualTo(2);
			hbmId.generator.param.Select(p => p.name).Should().Have.SameValuesAs("max_low", "where");
			hbmId.generator.param.Select(p => p.GetText()).Should().Have.SameValuesAs("99", "TableName");
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:9,代码来源:IdMapperTest.cs


示例9: CanSetGeneratorWithParameters

		public void CanSetGeneratorWithParameters()
		{
			var hbmId = new HbmId();
			new IdMapper(hbmId).Generator(Generators.HighLow, p => p.Params(new { max_low = 99, where = "TableName" }));
			Assert.That([email protected], Is.EqualTo("hilo"));
			Assert.That(hbmId.generator.param, Has.Length.EqualTo(2));
			Assert.That(hbmId.generator.param.Select(p => p.name), Is.EquivalentTo(new [] {"max_low", "where"}));
			Assert.That(hbmId.generator.param.Select(p => p.GetText()), Is.EquivalentTo(new [] {"99", "TableName"}));
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:9,代码来源:IdMapperTest.cs


示例10: CanSetGeneratorForeign

		public void CanSetGeneratorForeign()
		{
			var hbmId = new HbmId();
			new IdMapper(hbmId).Generator(Generators.Foreign<MyClass>(mc => mc.OneToOne));
			Assert.That([email protected], Is.EqualTo("foreign"));
			Assert.That(hbmId.generator.param, Is.Not.Null.And.Length.EqualTo(1));
			var p = hbmId.generator.param.Single();
			Assert.That(p.GetText(), Is.EqualTo("OneToOne"));
			Assert.That(p.name, Is.EqualTo("property"));
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:10,代码来源:IdMapperTest.cs


示例11: AddColumns

		private void AddColumns(HbmId idSchema, SimpleValue id)
		{
			if (idSchema.column1 != null)
				AddColumnFromAttribute(idSchema, id);
			else
				AddColumnsFromList(idSchema, id);

			if (id.ColumnSpan == 0)
				AddDefaultColumn(idSchema, id);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:10,代码来源:ClassIdBinder.cs


示例12: BindUnsavedValue

        private static void BindUnsavedValue(HbmId idSchema, SimpleValue id)
        {
            if (idSchema.unsavedvalue != null)
                id.NullValue = idSchema.unsavedvalue;

            else if (id.IdentifierGeneratorStrategy == "assigned")
                // TODO: H3 has id.setNullValue("undefined") here, but NH doesn't (yet) allow "undefined"
                // for id unsaved-value, so we use "null" here
                id.NullValue = "null";

            else
                id.NullValue = null;
        }
开发者ID:zibler,项目名称:zibler,代码行数:13,代码来源:ClassIdBinder.cs


示例13: CreateColumn

        private static Column CreateColumn(HbmId idSchema)
        {
            Column column = new Column();

            if (idSchema.length != null)
                column.Length = int.Parse(idSchema.length);

            column.IsNullable = false;
            column.IsUnique = false;
            column.CheckConstraint = string.Empty;
            column.SqlType = null;

            return column;
        }
开发者ID:zibler,项目名称:zibler,代码行数:14,代码来源:ClassIdBinder.cs


示例14: BindId

        public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
        {
            if (idSchema != null)
            {
                SimpleValue id = CreateIdentifier(idSchema, rootClass, table);

                AddColumns(idSchema, id);
                CreateIdentifierProperty(idSchema, rootClass, id);
                VerifiyIdTypeIsValid(id, rootClass.MappedClass.Name);
                BindGenerator(idSchema, id);
                id.Table.SetIdentifierValue(id);
                BindUnsavedValue(idSchema, id);
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:14,代码来源:ClassIdBinder.cs


示例15: Should_get_null_given_column_notnullSpecified_is_false

 public void Should_get_null_given_column_notnullSpecified_is_false()
 {
     HbmId id = new HbmId
         {
             column = new[]
                 {
                     new HbmColumn
                         {
                             notnullSpecified = false
                         }
                 }
         };
     bool? result = id.CanBeNull();
     result.ShouldBeNull();
 }
开发者ID:MelleKoning,项目名称:hbm-to-fnh,代码行数:15,代码来源:HbmIdExtensionsTests.cs


示例16: IdMapper

 public IdMapper(MemberInfo member, HbmId hbmId)
 {
     this.hbmId = hbmId;
     if (member != null)
     {
         var idType = member.GetPropertyOrFieldType();
         hbmId.name = member.Name;
         hbmId.type1 = idType.GetNhTypeName();
         accessorMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => hbmId.access = x);
     }
     else
     {
         accessorMapper = new NoMemberPropertyMapper();
     }
 }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:15,代码来源:IdMapper.cs


示例17: Should_get__true__given_column_notnullSpecified_is_true_and_notnull_is_false

 public void Should_get__true__given_column_notnullSpecified_is_true_and_notnull_is_false()
 {
     HbmId id = new HbmId
         {
             column = new[]
                 {
                     new HbmColumn
                         {
                             notnullSpecified = true,
                             notnull = false
                         }
                 }
         };
     bool? result = id.CanBeNull();
     result.ShouldNotBeNull();
     result.Value.ShouldBeTrue();
 }
开发者ID:MelleKoning,项目名称:hbm-to-fnh,代码行数:17,代码来源:HbmIdExtensionsTests.cs


示例18: ClassMapper

        public ClassMapper(Type rootClass, HbmMapping mapDoc, MemberInfo idProperty)
            : base(rootClass, mapDoc)
        {
            classMapping = new HbmClass();
            var toAdd = new[] { classMapping };
            classMapping.name = rootClass.GetShortClassName(mapDoc);
            if(rootClass.IsAbstract)
            {
                [email protected] = true;
                classMapping.abstractSpecified = true;
            }

            var hbmId = new HbmId();
            classMapping.Item = hbmId;
            idMapper = new IdMapper(idProperty, hbmId);

            mapDoc.Items = mapDoc.Items == null ? toAdd : mapDoc.Items.Concat(toAdd).ToArray();
        }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:18,代码来源:ClassMapper.cs


示例19: Should_get_the_correct_value_from_column

 public void Should_get_the_correct_value_from_column()
 {
     const string expected = "Name";
     HbmId id = new HbmId
         {
             column = new[]
                 {
                     new HbmColumn
                         {
                             index = expected
                         }
                 }
         };
     string result = id.GetUniqueIndex();
     result.ShouldNotBeNull();
     result.ShouldBeEqualTo(expected);
 }
开发者ID:MelleKoning,项目名称:hbm-to-fnh,代码行数:17,代码来源:HbmIdExtensionsTests.cs


示例20: Should_get_null_given_null_index_and_column_index

 public void Should_get_null_given_null_index_and_column_index()
 {
     HbmId id = new HbmId
         {
             column = new[] {new HbmColumn()}
         };
     string result = id.GetUniqueIndex();
     result.ShouldBeNull();
 }
开发者ID:MelleKoning,项目名称:hbm-to-fnh,代码行数:9,代码来源:HbmIdExtensionsTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MappingSchema.HbmManyToOne类代码示例发布时间:2022-05-26
下一篇:
C# Cfg.Configuration类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap