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