Castle.ActiveRecord.Framework.Internal.SemanticVerifierVisitor.VisitPrimaryKey C# (CSharp) Méthode

VisitPrimaryKey() public méthode

Visits the primary key.
Infer column name and the reverse property if using [OneToOne]
public VisitPrimaryKey ( PrimaryKeyModel model ) : void
model PrimaryKeyModel The model.
Résultat void
		public override void VisitPrimaryKey(PrimaryKeyModel model)
		{
			if (model.PrimaryKeyAtt.Column == null)
			{
				model.PrimaryKeyAtt.Column = model.Property.Name;
			}

			// Append column prefix
			model.PrimaryKeyAtt.Column = columnPrefix + model.PrimaryKeyAtt.Column;

			if (model.PrimaryKeyAtt.Generator == PrimaryKeyType.Foreign)
			{
				// Let's see if we are an OneToOne

				if (currentModel.OneToOnes.Count != 0)
				{
					// Yes, set the one to one as param 

					OneToOneModel oneToOne = (OneToOneModel) currentModel.OneToOnes[0];

					String param = "property=" + oneToOne.Property.Name;

					if (model.PrimaryKeyAtt.Params == null)
					{
						model.PrimaryKeyAtt.Params = param;
					}
					else
					{
						model.PrimaryKeyAtt.Params += "," + param;
					}
				}
			}
			else if (model.PrimaryKeyAtt.Generator == PrimaryKeyType.Custom)
			{
				if (model.PrimaryKeyAtt.CustomGenerator == null)
				{
					throw new ActiveRecordException(String.Format(
					                                	"A type defined that its primary key would use a custom generator, " +
					                                	"but apparently forgot to define the custom generator using PrimaryKeyAttribute.CustomGenerator property. " +
					                                	"Check type {0}", currentModel.Type.FullName));
				}

				if (!typeof(IIdentifierGenerator).IsAssignableFrom(model.PrimaryKeyAtt.CustomGenerator))
				{
					throw new ActiveRecordException(
						"The custom generator associated with the PK for the type " + currentModel.Type.FullName +
						"does not implement interface NHibernate.Id.IIdentifierGenerator");
				}
			}
		}