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


C# Relation.NeedsPositionStorage方法代码示例

本文整理汇总了C#中Relation.NeedsPositionStorage方法的典型用法代码示例。如果您正苦于以下问题:C# Relation.NeedsPositionStorage方法的具体用法?C# Relation.NeedsPositionStorage怎么用?C# Relation.NeedsPositionStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Relation的用法示例。


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

示例1: Call

        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Templates.Serialization.SerializationMembersList serializationList,
            Relation rel, RelationEndRole endRole, string backingCollectionType)
        {
            if (host == null) { throw new ArgumentNullException("host"); }
            if (rel == null) { throw new ArgumentNullException("rel"); }

            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string name = relEnd.Navigator.Name;
            string exposedCollectionInterface = rel.NeedsPositionStorage(otherEnd.GetRole()) ? "IList" : "ICollection";
            string referencedInterface = otherEnd.Type.GetDataTypeString();
            string backingName = "_" + name;

            string aSideType = rel.A.Type.GetDataTypeString();
            string bSideType = rel.B.Type.GetDataTypeString();
            string entryType = rel.GetRelationFullName() + host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
            string providerCollectionType = (rel.NeedsPositionStorage(otherEnd.GetRole()) ? "IList<" : "ICollection<")
                + entryType + ">";

            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
            bool serializeRelationEntries = rel.GetRelationType() == RelationType.n_m;

            string entryProxyType = entryType + "." + rel.GetRelationClassName() + "Proxy";

            string inverseNavigatorName = otherEnd.Navigator != null ? otherEnd.Navigator.Name : null;

            Call(host, ctx, serializationList, name, exposedCollectionInterface, referencedInterface, backingName, backingCollectionType, aSideType, bSideType, entryType, providerCollectionType, rel.ExportGuid, endRole, eagerLoading, serializeRelationEntries, entryProxyType, inverseNavigatorName);
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:31,代码来源:CollectionEntryListProperty.cs

示例2: ApplyIndexPropertyTemplate

        protected virtual void ApplyIndexPropertyTemplate(Relation rel, RelationEndRole endRole)
        {
            if (rel.NeedsPositionStorage(endRole))
            {
                // provided by ObjectReferencePropertyTemplate
                string posBackingStore = "_" + endRole + Zetbox.API.Helper.PositionSuffix;

                // is serialized by the ObjectReferenceProperty
                //this.MembersToSerialize.Add(
                //    Serialization.SerializerType.All,
                //    relEnd.Type.Module.Namespace,
                //    endRole + Zetbox.API.Helper.PositionSuffix,
                //    posBackingStore);

                this.WriteObjects("        public int? ", endRole, "Index { get { return ",
                    posBackingStore, "; } set { ",
                    posBackingStore, " = value; } }");
                this.WriteLine();
            }
            else if (IsOrdered())
            {
                this.WriteLine("/// <summary>ignored implementation for INewListEntry</summary>");
                this.WriteObjects("public int? ", endRole, "Index { get { return null; } set { } }");
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:25,代码来源:RelationEntry.Properties.cs

示例3: ApplyObjectReferenceProperty

        protected override void ApplyObjectReferenceProperty(Relation rel, RelationEndRole endRole, string propertyName)
        {
            // TODO: create/use ObjectReference*IMPLEMENTATION* instead (_fk* can already be made available)

            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string moduleNamespace = rel.Module.Namespace;
            string implName = propertyName + Zetbox.API.Helper.ImplementationSuffix;
            string eventName = "On" + propertyName;

            string fkBackingName = "_fk_" + propertyName;
            string fkGuidBackingName = "_fk_guid_" + propertyName;

            string referencedInterface = relEnd.Type.GetDataTypeString();
            string referencedImplementation = referencedInterface
                + Host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
            string associationName = rel.GetAssociationName() + "_" + endRole.ToString();
            string targetRoleName = relEnd.RoleName;

            string positionPropertyName = rel.NeedsPositionStorage(endRole)
                ? propertyName + Zetbox.API.Helper.PositionSuffix
                : null;

            string inverseNavigatorName = relEnd.Navigator != null
                ? relEnd.Navigator.Name + Zetbox.API.Helper.ImplementationSuffix
                : null;
            bool inverseNavigatorIsList = false;
            bool notifyInverseCollection = true;

            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
            bool relDataTypeExportable = rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable();
            bool callGetterSetterEvents = false;

            Templates.Properties.ObjectReferencePropertyTemplate.Call(Host,
                ctx,
                MembersToSerialize,
                moduleNamespace,
                "/* not member of an interface, 'ownInterface' should not be used */",
                propertyName,
                implName,
                eventName,
                fkBackingName,
                fkGuidBackingName,
                referencedInterface,
                referencedImplementation,
                associationName,
                targetRoleName,
                positionPropertyName,
                inverseNavigatorName,
                inverseNavigatorIsList,
                notifyInverseCollection,
                eagerLoading,
                relDataTypeExportable,
                callGetterSetterEvents,
                false, // ObjRef with relation cannot be calculated
                false);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:58,代码来源:RelationEntry.cs

示例4: ProcessRelationEnd

        private void ProcessRelationEnd(Relation rel, RelationEnd relEnd)
        {
            var otherEnd = rel.GetOtherEnd(relEnd);

            string columnName = Construct.ForeignKeyColumnName(otherEnd, prefix);
            bool needPositionStorage = rel.NeedsPositionStorage(relEnd.GetRole());
            string positionColumnName = Construct.ListPositionColumnName(otherEnd, prefix);

            GenerateProperty(
                columnName,
                needPositionStorage,
                positionColumnName);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:13,代码来源:Model.ssdl.EntityTypeColumnsRel.cs

示例5: DoChangeRelationType_from_1_n_to_1_1

        public void DoChangeRelationType_from_1_n_to_1_1(Relation rel)
        {
            var saved = savedSchema.FindPersistenceObject<Relation>(rel.ExportGuid);
            string srcAssocName = saved.GetAssociationName();

            RelationEnd relEnd, otherEnd;

            switch (saved.Storage)
            {
                case StorageType.MergeIntoA:
                    relEnd = saved.A;
                    otherEnd = saved.B;
                    break;
                case StorageType.MergeIntoB:
                    otherEnd = saved.A;
                    relEnd = saved.B;
                    break;
                default:
                    Log.ErrorFormat("Relation '{0}' has unsupported Storage set: {1}, skipped", srcAssocName, rel.Storage);
                    return;
            }

            var srcTblName = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            string srcColName = Construct.ForeignKeyColumnName(otherEnd);
            bool srcIsIndexed = rel.NeedsPositionStorage(relEnd.GetRole());
            string srcIndexName = Construct.ListPositionColumnName(otherEnd);

            if (!db.CheckFKColumnContainsUniqueValues(srcTblName, srcColName))
            {
                Log.ErrorFormat("Unable to change Relation '{0}' from 1:n to 1:1. Data is not unique", srcAssocName);
                return;
            }

            if (db.CheckFKConstraintExists(srcTblName, srcAssocName))
                db.DropFKConstraint(srcTblName, srcAssocName);
            if (srcIsIndexed && db.CheckColumnExists(srcTblName, srcIndexName))
                db.DropColumn(srcTblName, srcIndexName);
            if (db.CheckIndexExists(srcTblName, Construct.IndexName(srcTblName.Name, srcColName)))
                db.DropIndex(srcTblName, Construct.IndexName(srcTblName.Name, srcColName));

            bool aCreated = false;
            bool bCreated = false;

            // Difference to 1:N. 1:1 may have storage 'Replicate'
            // First try to migrate columns
            // And only migrate because the source data might be used twice
            if (rel.HasStorage(RelationEndRole.A))
            {
                var destTblName = db.GetTableName(rel.A.Type.Module.SchemaName, rel.A.Type.TableName);
                var destColName = Construct.ForeignKeyColumnName(rel.B);
                if (destTblName != srcTblName)
                {
                    New_1_1_Relation_CreateColumns(rel, rel.A, rel.B, RelationEndRole.A);
                    db.MigrateFKs(srcTblName, srcColName, destTblName, destColName);
                    aCreated = true;
                }
            }
            if (rel.HasStorage(RelationEndRole.B))
            {
                var destTblName = db.GetTableName(rel.B.Type.Module.SchemaName, rel.B.Type.TableName);
                var destColName = Construct.ForeignKeyColumnName(rel.A);
                if (destTblName != srcTblName)
                {
                    New_1_1_Relation_CreateColumns(rel, rel.B, rel.A, RelationEndRole.B);
                    db.MigrateFKs(srcTblName, srcColName, destTblName, destColName);
                    bCreated = true;
                }
            }
            bool srcColWasReused = false;
            // Then try to rename columns
            if (rel.HasStorage(RelationEndRole.A) && !aCreated)
            {
                var destTblName = db.GetTableName(rel.A.Type.Module.SchemaName, rel.A.Type.TableName);
                var destColName = Construct.ForeignKeyColumnName(rel.B);
                if (destTblName == srcTblName && destColName != srcColName)
                {
                    db.RenameColumn(destTblName, srcColName, destColName);
                }
                var assocName = rel.GetRelationAssociationName(RelationEndRole.A);
                var refTblName = db.GetTableName(rel.B.Type.Module.SchemaName, rel.B.Type.TableName);
                db.CreateFKConstraint(destTblName, refTblName, destColName, assocName, false);
                db.CreateIndex(destTblName, Construct.IndexName(destTblName.Name, destColName), true, false, destColName);
                srcColWasReused = true;
            }
            if (rel.HasStorage(RelationEndRole.B) && !bCreated)
            {
                var destTblName = db.GetTableName(rel.B.Type.Module.SchemaName, rel.B.Type.TableName);
                var destColName = Construct.ForeignKeyColumnName(rel.A);
                if (destTblName == srcTblName && destColName != srcColName)
                {
                    db.RenameColumn(destTblName, srcColName, destColName);
                }
                var assocName = rel.GetRelationAssociationName(RelationEndRole.B);
                var refTblName = db.GetTableName(rel.A.Type.Module.SchemaName, rel.A.Type.TableName);
                db.CreateFKConstraint(destTblName, refTblName, destColName, assocName, false);
                db.CreateIndex(destTblName, Construct.IndexName(destTblName.Name, destColName), true, false, destColName);
                srcColWasReused = true;
            }

            if (!srcColWasReused && db.CheckColumnExists(srcTblName, srcColName))
//.........这里部分代码省略.........
开发者ID:jrgcubano,项目名称:zetbox,代码行数:101,代码来源:Cases.cs

示例6: DoNew_1_N_Relation

        public void DoNew_1_N_Relation(Relation rel)
        {
            string assocName = rel.GetAssociationName();
            Log.InfoFormat("New 1:N Relation: {0}", assocName);

            RelationEnd relEnd, otherEnd;

            switch (rel.Storage)
            {
                case StorageType.MergeIntoA:
                    relEnd = rel.A;
                    otherEnd = rel.B;
                    break;
                case StorageType.MergeIntoB:
                    otherEnd = rel.A;
                    relEnd = rel.B;
                    break;
                default:
                    Log.ErrorFormat("Relation '{0}' has unsupported Storage set: {1}, skipped", assocName, rel.Storage);
                    return;
            }

            var tblName = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            var refTblName = db.GetTableName(otherEnd.Type.Module.SchemaName, otherEnd.Type.TableName);
            bool isIndexed = rel.NeedsPositionStorage(relEnd.GetRole());

            var colName = Construct.ForeignKeyColumnName(otherEnd);
            var indexName = Construct.ListPositionColumnName(otherEnd);

            CreateFKColumn(otherEnd, tblName, colName);
            db.CreateFKConstraint(tblName, refTblName, colName, assocName, false);
            db.CreateIndex(tblName, Construct.IndexName(tblName.Name, colName), false, false, colName);

            if (isIndexed)
            {
                Log.InfoFormat("Creating position column '{0}.{1}'", tblName, indexName);
                db.CreateColumn(tblName, indexName, System.Data.DbType.Int32, 0, 0, true);
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:39,代码来源:Cases.cs

示例7: New_1_1_Relation_CreateColumns

        private void New_1_1_Relation_CreateColumns(Relation rel, RelationEnd relEnd, RelationEnd otherEnd, RelationEndRole role)
        {
            var tblName = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            var refTblName = db.GetTableName(otherEnd.Type.Module.SchemaName, otherEnd.Type.TableName);
            var colName = Construct.ForeignKeyColumnName(otherEnd);
            var assocName = rel.GetRelationAssociationName(role);
            var idxName = Construct.IndexName(tblName.Name, colName);

            CreateFKColumn(otherEnd, tblName, colName);
            db.CreateFKConstraint(tblName, refTblName, colName, assocName, false);
            if (db.CheckIndexPossible(tblName, idxName, true, false, colName))
                db.CreateIndex(tblName, idxName, true, false, colName);
            else
                Log.WarnFormat("Cannot create index: {0}", idxName);

            if (rel.NeedsPositionStorage(role))
            {
                Log.ErrorFormat("1:1 Relation should never need position storage, but this one does!");
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:20,代码来源:Cases.cs

示例8: DoChangeRelationType_from_1_1_to_1_n

        public void DoChangeRelationType_from_1_1_to_1_n(Relation rel)
        {
            var saved = savedSchema.FindPersistenceObject<Relation>(rel.ExportGuid);

            string destAssocName = rel.GetAssociationName();
            Log.InfoFormat("Changing 1:1 Relation to 1:N: {0}", destAssocName);

            RelationEnd relEnd, otherEnd;

            switch (rel.Storage)
            {
                case StorageType.MergeIntoA:
                    relEnd = rel.A;
                    otherEnd = rel.B;
                    break;
                case StorageType.MergeIntoB:
                    otherEnd = rel.A;
                    relEnd = rel.B;
                    break;
                default:
                    Log.ErrorFormat("Relation '{0}' has unsupported Storage set: {1}, skipped", destAssocName, rel.Storage);
                    return;
            }

            var destTblRef = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            var destRefTblName = db.GetTableName(otherEnd.Type.Module.SchemaName, otherEnd.Type.TableName);
            bool isIndexed = rel.NeedsPositionStorage(relEnd.GetRole());

            string destColName = Construct.ForeignKeyColumnName(otherEnd);
            string destIndexName = Construct.ListPositionColumnName(otherEnd);

            string srcSchemaName = string.Empty;
            string srcTblName = string.Empty;
            string srcColName = string.Empty;

            // Difference to 1:N. 1:1 may have storage 'Replicate'
            // use best matching
            if (saved.HasStorage(RelationEndRole.A))
            {
                srcSchemaName = saved.A.Type.Module.SchemaName;
                srcTblName = saved.A.Type.TableName;
                srcColName = Construct.ForeignKeyColumnName(saved.B);
            }
            if (saved.HasStorage(RelationEndRole.B) && (string.IsNullOrEmpty(srcSchemaName) || string.IsNullOrEmpty(srcTblName) || db.GetTableName(srcSchemaName, srcTblName) != destTblRef))
            {
                srcSchemaName = saved.B.Type.Module.SchemaName;
                srcTblName = saved.B.Type.TableName;
                srcColName = Construct.ForeignKeyColumnName(saved.A);
            }

            var srcTblRef = db.GetTableName(srcSchemaName, srcTblName);
            var idxName = Construct.IndexName(srcTblName, srcColName);

            if (srcTblRef == destTblRef && srcColName == destColName)
            {
                if (db.CheckIndexExists(srcTblRef, idxName))
                    db.DropIndex(srcTblRef, idxName);
            }
            else if (srcTblRef == destTblRef && srcColName != destColName)
            {
                db.RenameColumn(srcTblRef, srcColName, destColName);
                if (db.CheckIndexExists(srcTblRef, idxName))
                    db.DropIndex(srcTblRef, idxName);
            }
            else
            {
                db.CreateColumn(destTblRef, destColName, System.Data.DbType.Int32, 0, 0, true);
                db.MigrateFKs(srcTblRef, srcColName, destTblRef, destColName);
                if (!otherEnd.IsNullable())
                {
                    if (!db.CheckColumnContainsNulls(destTblRef, destColName))
                    {
                        db.AlterColumn(destTblRef, destColName, System.Data.DbType.Int32, 0, 0, false, null);
                    }
                    else
                    {
                        Log.ErrorFormat("Unable to alter NOT NULL column, since table contains data. Leaving nullable column instead");
                    }
                }
            }

            db.CreateFKConstraint(destTblRef, destRefTblName, destColName, destAssocName, false);
            db.CreateIndex(destTblRef, Construct.IndexName(destTblRef.Name, destColName), false, false, destColName);
            if (isIndexed)
            {
                Log.InfoFormat("Creating position column '{0}.{1}'", destTblRef, destIndexName);
                db.CreateColumn(destTblRef, destIndexName, System.Data.DbType.Int32, 0, 0, true);
            }

            // Cleanup
            if (saved.HasStorage(RelationEndRole.A))
            {
                srcTblName = saved.A.Type.TableName;
                srcColName = Construct.ForeignKeyColumnName(saved.B);
                var srcAssocName = saved.GetRelationAssociationName(RelationEndRole.A);

                if (db.CheckFKConstraintExists(srcTblRef, srcAssocName))
                    db.DropFKConstraint(srcTblRef, srcAssocName);
                if (srcTblRef != destTblRef || srcColName != destColName)
                {
//.........这里部分代码省略.........
开发者ID:jrgcubano,项目名称:zetbox,代码行数:101,代码来源:Cases.cs

示例9: DoNew_N_M_Relation

        public void DoNew_N_M_Relation(Relation rel)
        {
            if (!PreMigration(RelationMigrationEventType.Add, null, rel))
                return;

            string assocName, fkAName, fkBName;
            TableRef tblName;
            ObjectClass aType, bType;
            if (!TryInspect_N_M_Relation(rel, out assocName, out tblName, out fkAName, out fkBName, out aType, out bType))
            {
                return;
            }

            Log.InfoFormat("New N:M Relation: {0}", assocName);
            if (db.CheckTableExists(tblName))
            {
                Log.ErrorFormat("Relation table {0} already exists", tblName);
                return;
            }

            db.CreateTable(tblName, true);

            db.CreateColumn(tblName, fkAName, System.Data.DbType.Int32, 0, 0, false);
            if (rel.NeedsPositionStorage(RelationEndRole.A))
            {
                db.CreateColumn(tblName, fkAName + Zetbox.API.Helper.PositionSuffix, System.Data.DbType.Int32, 0, 0, true);
            }

            db.CreateColumn(tblName, fkBName, System.Data.DbType.Int32, 0, 0, false);
            if (rel.NeedsPositionStorage(RelationEndRole.B))
            {
                db.CreateColumn(tblName, fkBName + Zetbox.API.Helper.PositionSuffix, System.Data.DbType.Int32, 0, 0, true);
            }

            if (aType.ImplementsIExportable() && bType.ImplementsIExportable())
            {
                db.CreateColumn(tblName, "ExportGuid", System.Data.DbType.Guid, 0, 0, false, new NewGuidDefaultConstraint());
            }

            db.CreateFKConstraint(tblName, aType.GetTableRef(db), fkAName, rel.GetRelationAssociationName(RelationEndRole.A), false);
            db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkAName), false, false, fkAName);
            db.CreateFKConstraint(tblName, bType.GetTableRef(db), fkBName, rel.GetRelationAssociationName(RelationEndRole.B), false);
            db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkBName), false, false, fkBName);

            if (schema.GetQuery<RoleMembership>().Where(rm => rm.Relations.Contains(rel)).Count() > 0)
            {
                // Relation is in a ACL selector
                DoCreateUpdateRightsTrigger(rel);
            }

            PostMigration(RelationMigrationEventType.Add, null, rel);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:52,代码来源:Cases.cs

示例10: Delete_1_1_Relation_DropColumns

        private void Delete_1_1_Relation_DropColumns(Relation rel, RelationEnd relEnd, RelationEnd otherEnd, RelationEndRole role)
        {
            var tblName = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            var colName = Construct.ForeignKeyColumnName(otherEnd);
            var assocName = rel.GetRelationAssociationName(role);

            if (db.CheckFKConstraintExists(tblName, assocName))
                db.DropFKConstraint(tblName, assocName);
            if (db.CheckColumnExists(tblName, colName))
                db.DropColumn(tblName, colName);

            if (rel.NeedsPositionStorage(role) && db.CheckColumnExists(tblName, Construct.ListPositionColumnName(otherEnd)))
                db.DropColumn(tblName, Construct.ListPositionColumnName(otherEnd));
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:14,代码来源:Cases.cs

示例11: TryInspect_1_N_Relation

        /// <summary>
        /// Tries to dissect a relation for the 1_N case.
        /// </summary>
        /// <returns>false if something is wrong with the relation definition. The out parameters are only filled correctly when the function returns true.</returns>
        internal bool TryInspect_1_N_Relation(
            Relation rel, out string assocName,
            out RelationEnd relEnd, out RelationEnd otherEnd,
            out TableRef tblName, out TableRef refTblName,
            out string colName,
            out bool hasPersistentOrder, out string listPosName)
        {
            assocName = rel.GetAssociationName();

            switch (rel.Storage)
            {
                case StorageType.MergeIntoA:
                    relEnd = rel.A;
                    otherEnd = rel.B;
                    break;
                case StorageType.MergeIntoB:
                    otherEnd = rel.A;
                    relEnd = rel.B;
                    break;
                default:
                    Log.ErrorFormat("Skipping Relation '{0}': unsupported Storage set: {1}", assocName, rel.Storage);
                    otherEnd = null;
                    relEnd = null;
                    tblName = null;
                    refTblName = null;
                    hasPersistentOrder = default(bool);
                    colName = null;
                    listPosName = null;
                    return false;
            }

            tblName = relEnd.Type.GetTableRef(db);
            refTblName = otherEnd.Type.GetTableRef(db);
            hasPersistentOrder = rel.NeedsPositionStorage(relEnd.GetRole());

            colName = Construct.ForeignKeyColumnName(otherEnd);
            listPosName = Construct.ListPositionColumnName(otherEnd);

            return true;
        }
开发者ID:daszat,项目名称:zetbox,代码行数:44,代码来源:Cases.cs

示例12: Call

        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Serialization.SerializationMembersList serializationList,
            string ownInterface,
            string name,
            string referencedInterface,
            Relation rel,
            RelationEndRole endRole,
            bool callGetterSetterEvents,
            bool updateInverseNavigator,
            string assocNameSuffix)
        {
            // TODO: split off relation expansion in own Call() method
            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            string moduleNamespace = rel.Module.Namespace;
            string implName = name + Zetbox.API.Helper.ImplementationSuffix;
            string eventName = "On" + name;

            string fkBackingName = "_fk_" + name;
            string fkGuidBackingName = "_fk_guid_" + name;

            string referencedImplementation = referencedInterface
                + host.Settings["extrasuffix"] + Zetbox.API.Helper.ImplementationSuffix;
            string associationName = rel.GetAssociationName() + assocNameSuffix;
            string targetRoleName = otherEnd.RoleName;

            string positionPropertyName = rel.NeedsPositionStorage(endRole)
                ? Construct.ListPositionPropertyName(relEnd)
                : null;

            string inverseNavigatorName = updateInverseNavigator && otherEnd.Navigator != null
                ? otherEnd.Navigator.Name
                : null;
            bool inverseNavigatorIsList = otherEnd.Navigator != null && otherEnd.Navigator.GetIsList();

            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
            bool relDataTypeExportable = rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable();

            Call(host,
                ctx,
                serializationList,
                moduleNamespace,
                ownInterface,
                name,
                implName,
                eventName,
                fkBackingName,
                fkGuidBackingName,
                referencedInterface,
                referencedImplementation,
                associationName,
                targetRoleName,
                positionPropertyName,
                inverseNavigatorName,
                inverseNavigatorIsList,
                eagerLoading,
                relDataTypeExportable,
                callGetterSetterEvents,
                false, // ObjRef with relation cannot be calculated
                false);
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:63,代码来源:ObjectReferencePropertyTemplate.cs

示例13: Check_1_N_RelationColumns

        private void Check_1_N_RelationColumns(Relation rel)
        {
            string assocName = rel.GetAssociationName();

            RelationEnd relEnd, otherEnd;

            switch (rel.Storage)
            {
                case StorageType.MergeIntoA:
                    relEnd = rel.A;
                    otherEnd = rel.B;
                    break;
                case StorageType.MergeIntoB:
                    otherEnd = rel.A;
                    relEnd = rel.B;
                    break;
                default:
                    Log.ErrorFormat("Relation '{0}' has unsupported Storage set: {1}, skipped", assocName, rel.Storage);
                    return;
            }

            var tblName = relEnd.Type.GetTableRef(db);
            var refTblName = otherEnd.Type.GetTableRef(db);
            bool isIndexed = rel.NeedsPositionStorage(relEnd.GetRole());

            string colName = Construct.ForeignKeyColumnName(otherEnd);
            string indexName = Construct.ListPositionColumnName(otherEnd);

            var realIsNullable = otherEnd.IsNullable();
            if (realIsNullable == false)
                realIsNullable = relEnd.Type.GetTableMapping() == TableMapping.TPH && relEnd.Type.BaseObjectClass != null;

            CheckColumn(tblName, colName, System.Data.DbType.Int32, 0, 0, realIsNullable, null);

            if (!db.CheckFKConstraintExists(tblName, assocName))
            {
                Log.WarnFormat("FK Constraint '{0}' is missing", assocName);
                if (repair)
                {
                    db.CreateFKConstraint(tblName, refTblName, colName, assocName, false);
                }
            }

            if (!db.CheckIndexExists(tblName, Construct.IndexName(tblName.Name, colName)))
            {
                Log.WarnFormat("Index '{0}' is missing", Construct.IndexName(tblName.Name, colName));
                if (repair)
                {
                    db.CreateIndex(tblName, Construct.IndexName(tblName.Name, colName), false, false, colName);
                }
            }

            if (isIndexed)
            {
                CheckOrderColumn(tblName, colName, indexName);
            }
            if (!isIndexed && db.CheckColumnExists(tblName, indexName))
            {
                Log.WarnFormat("Index Column exists but property is not indexed");
                if (repair)
                {
                    Case.Do_1_N_RelationChange_FromIndexed_To_NotIndexed(rel);
                }
            }
        }
开发者ID:daszat,项目名称:zetbox,代码行数:65,代码来源:SchemaManager.CheckSchema.cs

示例14: DoDelete_1_N_Relation

        public void DoDelete_1_N_Relation(Relation rel)
        {
            string assocName = rel.GetAssociationName();
            Log.InfoFormat("Deleting 1:N Relation: {0}", assocName);

            TableRef tblName;
            bool isIndexed = false;
            RelationEnd otherEnd;
            if (rel.HasStorage(RelationEndRole.A))
            {
                tblName = db.GetTableName(rel.A.Type.Module.SchemaName, rel.A.Type.TableName);
                isIndexed = rel.NeedsPositionStorage(RelationEndRole.A);
                otherEnd = rel.B;
            }
            else if (rel.HasStorage(RelationEndRole.B))
            {
                tblName = db.GetTableName(rel.B.Type.Module.SchemaName, rel.B.Type.TableName);
                isIndexed = rel.NeedsPositionStorage(RelationEndRole.B);
                otherEnd = rel.A;
            }
            else
            {
                Log.ErrorFormat("Relation '{0}' has unsupported Storage set: {1}, skipped", assocName, rel.Storage);
                return;
            }

            if (db.CheckFKConstraintExists(tblName, assocName))
                db.DropFKConstraint(tblName, assocName);

            string colName = Construct.ForeignKeyColumnName(otherEnd);

            if (db.CheckColumnExists(tblName, colName))
                db.DropColumn(tblName, colName);

            if (isIndexed && db.CheckColumnExists(tblName, Construct.ListPositionColumnName(otherEnd)))
                db.DropColumn(tblName, Construct.ListPositionColumnName(otherEnd));
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:37,代码来源:Cases.cs

示例15: RelationToBackingCollectionType

        public static string RelationToBackingCollectionType(Relation rel, RelationEnd otherEnd)
        {
            if (rel == null) { throw new ArgumentNullException("rel"); }
            if (otherEnd == null) { throw new ArgumentNullException("otherEnd"); }

            string result;

            if (rel.NeedsPositionStorage(otherEnd.GetRole()))
            {
                result = String.Format("NHibernate{0}SideListWrapper", otherEnd.GetRole());
            }
            else
            {
                result = String.Format("NHibernate{0}SideCollectionWrapper", otherEnd.GetRole());
            }

            return result;
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:18,代码来源:CollectionEntryListProperty.cs


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