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


C# MappingSchema.HbmId类代码示例

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


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


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