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


C# Mapping.SimpleValue类代码示例

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


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

示例1: UnmatchingColumns

		public void UnmatchingColumns()
		{
			Table primaryTable = new Table("pktable");
			primaryTable.PrimaryKey = new PrimaryKey();
			SimpleValue sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.Int16.Name;
			Column pkColumn = new Column("pk_column");
			pkColumn.Value = sv;

			primaryTable.PrimaryKey.AddColumn(pkColumn);

			Table fkTable = new Table("fktable");

			ForeignKey fk = new ForeignKey();
			sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.Int16.Name;
			Column fkColumn1 = new Column("col1");
			fkColumn1.Value = sv;

			sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.Int16.Name;
			Column fkColumn2 = new Column("col2");
			fkColumn2.Value = sv;

			fk.AddColumn(fkColumn1);
			fk.AddColumn(fkColumn2);

			fk.Table = fkTable;

			fk.ReferencedTable = primaryTable;
			Assert.Throws<FKUnmatchingColumnsException>(() => fk.AlignColumns());
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:32,代码来源:ForeignKeyFixture.cs

示例2: BindTimestamp

		private void BindTimestamp(HbmTimestamp timestampSchema, PersistentClass rootClass, Table table)
		{
			if (timestampSchema == null)
				return;

			string propertyName = timestampSchema.name;
			SimpleValue simpleValue = new SimpleValue(table);

			BindColumns(timestampSchema, simpleValue, propertyName);

			if (!simpleValue.IsTypeSpecified)
				simpleValue.TypeName = NHibernateUtil.Timestamp.Name;

			Mapping.Property property = new Mapping.Property(simpleValue);
			BindProperty(timestampSchema, property);

			// for version properties marked as being generated, make sure they are "always"
			// generated; "insert" is invalid. This is dis-allowed by the schema, but just to make
			// sure...

			if (property.Generation == PropertyGeneration.Insert)
				throw new MappingException("'generated' attribute cannot be 'insert' for versioning property");

			simpleValue.NullValue = timestampSchema.unsavedvalue;
			rootClass.Version = property;
			rootClass.AddProperty(property);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:27,代码来源:RootClassBinder.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: BindSimpleValue

		private void BindSimpleValue(HbmDiscriminator discriminatorSchema, SimpleValue discriminator)
		{
			if (discriminatorSchema.type != null)
				discriminator.TypeName = discriminatorSchema.type;

			if (discriminatorSchema.formula != null)
			{
				var f = new Formula {FormulaString = discriminatorSchema.formula};
				discriminator.AddFormula(f);
			}
			else
			{
				new ColumnsBinder(discriminator, Mappings).Bind(discriminatorSchema.Columns, false,
				                                                () =>
				                                                new HbmColumn
				                                                	{
				                                                		name =
				                                                			mappings.NamingStrategy.PropertyToColumnName(
				                                                			RootClass.DefaultDiscriminatorColumnName),
				                                                		length = discriminatorSchema.length,
																														notnull = discriminatorSchema.notnull,
																														notnullSpecified = true
				                                                	});
			}
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:25,代码来源:ClassDiscriminatorBinder.cs

示例6: BindGenerator

		public void BindGenerator(SimpleValue id, HbmGenerator generatorMapping)
		{
			if (generatorMapping != null)
			{
				if ([email protected] == null)
					throw new MappingException("no class given for generator");

				// NH Differen behavior : specific feature NH-1817
				TypeDef typeDef = mappings.GetTypeDef([email protected]);
				if (typeDef != null)
				{
					id.IdentifierGeneratorStrategy = typeDef.TypeClass;
					// parameters on the property mapping should override parameters in the typedef
					var allParameters = new Dictionary<string, string>(typeDef.Parameters);
					ArrayHelper.AddAll(allParameters, GetGeneratorProperties(generatorMapping, id.Table.Schema));

					id.IdentifierGeneratorProperties = allParameters;
				}
				else
				{
					id.IdentifierGeneratorStrategy = [email protected];
					id.IdentifierGeneratorProperties = GetGeneratorProperties(generatorMapping, id.Table.Schema);
				}
			}
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:25,代码来源:IdGeneratorBinder.cs

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

示例8: BindColumn

 protected virtual void BindColumn(SimpleValue model, ColumnMapping columnMapping)
 {
     Table table = model.Table;
     var column = CreateColumn(model, columnMapping);
     if (table != null)
         table.AddColumn(column);
     model.AddColumn(column);
 }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:8,代码来源:ClassBinder.cs

示例9: YesNoSqlType

		public void YesNoSqlType()
		{
			SimpleValue sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.YesNo.Name;
			Column column = new Column();
			column.Value = sv;
			string type = column.GetSqlType(_dialect, null);
			Assert.AreEqual("CHAR(1)", type);
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:9,代码来源:ColumnFixture.cs

示例10: TypeBinder

		public TypeBinder(SimpleValue value, Mappings mappings)
			: base(mappings)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			this.value = value;
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:9,代码来源:TypeBinder.cs

示例11: BindFk

		public static void BindFk(PersistentClass referencedEntity,
		                          PersistentClass destinationEntity,
		                          Ejb3JoinColumn[] columns,
		                          SimpleValue value,
		                          bool unique,
		                          ExtendedMappings mappings)
		{
			throw new NotImplementedException();
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:9,代码来源:TableBinder.cs

示例12: MakeVersion

 public static void MakeVersion(XmlNode node, SimpleValue model)
 {
     if (node != null && node.Attributes != null)
     {
         XmlAttribute attribute = node.Attributes["unsaved-value"];
         model.NullValue = attribute == null ? null : attribute.Value;
     }
     else
         model.NullValue = null;
 }
开发者ID:zibler,项目名称:zibler,代码行数:10,代码来源:RootClassBinder.cs

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

示例14: StringSqlType

		public void StringSqlType()
		{
			SimpleValue sv = new SimpleValue();
			sv.TypeName = NHibernateUtil.String.Name;
			Column column = new Column();
			column.Value = sv;
			Assert.AreEqual("NVARCHAR(255)", column.GetSqlType(_dialect, null));

			column.Length = 100;
			Assert.AreEqual("NVARCHAR(100)", column.GetSqlType(_dialect, null));
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:11,代码来源:ColumnFixture.cs

示例15: CheckDefaultUnsavedValue

		private void CheckDefaultUnsavedValue( string versionTag )
		{
			string XML = GetXmlForTesting( versionTag );
			XmlDocument document = LoadAndValidate( XML );
			XmlNode node = document.GetElementsByTagName( versionTag )[0];
			SimpleValue model = new SimpleValue();
			Binder.MakeVersion( node, model );
			Assert.IsNull( model.NullValue,
				"default unsaved-value for tag {0} should be null, but is '{1}'",
				versionTag, model.NullValue );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:11,代码来源:BinderFixture.cs


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