/// <summary> /// Creates the generator metaobject if it doesn't exists for primaryid that is simple and defined with autoincremental option /// </summary> private void CreateGenerator() { if (PrimaryId == null || !PrimaryId.IsAutoincrement) { return; } Generator gen = new Generator(this); if (Model.Generators.GetByName(gen.FullName) == null) { if (PrimaryId.Attribute.Type is ScalarType) { ScalarType t = (PrimaryId.Attribute.Type as ScalarType); if (PrimaryId.Attribute.HasMaxValue) { gen.MaxValue = PrimaryId.Attribute.MaxValue; gen.HasMaxValue = true; } else if (t.MaxValue.HasValue) { gen.MaxValue = t.MaxValue.Value; gen.HasMaxValue = true; } } PrimaryId.Generator = gen; Model.Generators.Add(gen); } }
public Attribute(Entity owner, string name, ScalarType type) : base(owner) { this.name = name; this.isDeclared = false; this.typeName = new QualName(type.FullName, owner.Schema); attrType = type; typeDefinition = new TypeDefinition(type.TypeDefinition); persistence = new Persistence(this, true, false, owner.Persistence.Schema, false, name, false, Const.EmptyName); }
public Metamodel.Attribute AddAttribute(string name, ScalarType type) { Metamodel.Attribute a = new Metamodel.Attribute(this, name, type); this.Attributes.Add(a); return(a); }