コード例 #1
0
ファイル: ClassIdBinder.cs プロジェクト: pallmall/WCell
		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);
			}
		}
コード例 #2
0
		public SimpleValue FillSimpleValue(SimpleValue simpleValue)
		{
			string type = BinderHelper.IsDefault(explicitType) ? returnedClassName : explicitType;
			TypeDef typeDef = mappings.GetTypeDef(type);
			if (typeDef != null)
			{
				type = typeDef.TypeClass;
				simpleValue.TypeParameters = typeDef.Parameters;
			}
			if (typeParameters != null && typeParameters.Count != 0)
			{
				//explicit type params takes precedence over type def params
				simpleValue.TypeParameters = typeParameters;
			}
			simpleValue.TypeName = type;
			if (persistentClassName != null)
			{
				simpleValue.SetTypeUsingReflection(persistentClassName, propertyName,"");
			}
			foreach (Ejb3Column column in columns)
			{
				column.linkWithValue(simpleValue);
			}
			return simpleValue;
		}
コード例 #3
0
		private Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass,
			HbmKeyProperty keyPropertySchema)
		{
			if (parentClass != null && value.IsSimpleValue)
				value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName,
				                             keyPropertySchema.access ?? mappings.DefaultAccess);

			// This is done here 'cos we might only know the type here (ugly!)
			var toOne = value as ToOne;
			if (toOne != null)
			{
				string propertyRef = toOne.ReferencedPropertyName;
				if (propertyRef != null)
					mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef);
			}

			value.CreateForeignKey();
			var prop = new Property {Value = value};
			BindProperty(keyPropertySchema, prop);

			return prop;
		}