public static void Call(Arebis.CodeGeneration.IGenerationHost _host, string prefix, ValueTypeProperty prop, string propName, string columnName, bool forceDefinition, string implementationSuffix, bool needsConcurrency) { if (_host == null) { throw new ArgumentNullException("_host"); } // shortcut unmapped properties if (prop.IsCalculated) { _host.WriteOutput(string.Format("<!-- ValueTypeProperty {0} is calculated and persisted -->\n", prop.Name)); } propName = string.IsNullOrEmpty(propName) ? prop.Name : propName; columnName = string.IsNullOrEmpty(columnName) ? propName : columnName; var optimisticLock = needsConcurrency && propName == "ChangedOn"; string typeAttr = String.Empty; if (prop is DateTimeProperty) { typeAttr = "type=\"Timestamp\""; } string ceClassAttr; if (prop.IsList && !forceDefinition) { // set the proper type for collection entries ceClassAttr = String.Format("class=\"{0}.{1}{2}+{1}Proxy,Zetbox.Objects.NHibernateImpl\"", prop.GetCollectionEntryNamespace(), prop.GetCollectionEntryClassName(), implementationSuffix); } else { // not needed ceClassAttr = String.Empty; } string ceReverseKeyColumnName = prop.GetCollectionEntryReverseKeyColumnName(); string listPositionColumnName = Construct.ListPositionColumnName(prop); Call(_host, prefix, propName, columnName, prop.IsList && !forceDefinition, typeAttr, ceClassAttr, ceReverseKeyColumnName, listPositionColumnName, optimisticLock); }
public void DoNewValueTypePropertyList(ObjectClass objClass, ValueTypeProperty prop) { Log.InfoFormat("New ValueType Property List: {0}", prop.Name); var tblName = db.GetTableName(prop.Module.SchemaName, prop.GetCollectionEntryTable()); string fkName = prop.GetCollectionEntryReverseKeyColumnName(); string valPropName = prop.Name; string valPropIndexName = prop.Name + "Index"; string assocName = prop.GetAssociationName(); bool hasPersistentOrder = prop.HasPersistentOrder; db.CreateTable(tblName, true); db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false); db.CreateColumn(tblName, valPropName, prop.GetDbType(), prop.GetSize(), prop.GetScale(), false, SchemaManager.GetDefaultConstraint(prop)); if (hasPersistentOrder) { db.CreateColumn(tblName, valPropIndexName, System.Data.DbType.Int32, 0, 0, false); } db.CreateFKConstraint(tblName, db.GetTableName(objClass.Module.SchemaName, objClass.TableName), fkName, assocName, true); db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkName), false, false, fkName); }