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


C# Relation.GetEndFromRole方法代码示例

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


在下文中一共展示了Relation.GetEndFromRole方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: Do1_1_RelationChange_FromNotNullable_To_Nullable

        public void Do1_1_RelationChange_FromNotNullable_To_Nullable(Relation rel, RelationEndRole role)
        {
            RelationEnd relEnd = rel.GetEndFromRole(role);
            RelationEnd otherEnd = rel.GetOtherEndFromRole(role);

            var tblName = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            var colName = Construct.ForeignKeyColumnName(otherEnd);

            if (db.CheckColumnContainsNulls(tblName, colName))
            {
                Log.ErrorFormat("column '{0}.{1}' contains NULL values, cannot set NOT NULLABLE", tblName, colName);
            }
            else
            {
                db.AlterColumn(tblName, colName, System.Data.DbType.Int32, 0, 0, otherEnd.IsNullable(), null);
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:17,代码来源:Cases.cs

示例4: ApplyObjectReferenceProperty

        protected override void ApplyObjectReferenceProperty(Relation rel, RelationEndRole endRole, string propertyName)
        {
            RelationEnd relEnd = rel.GetEndFromRole(endRole);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            // TODO: create/use ObjectReference*IMPLEMENTATION* instead (_fk* can already be made available)
            string moduleNamespace = rel.Module.Namespace;
            string ownInterface = moduleNamespace + "." + rel.GetRelationClassName() + ImplementationSuffix;
            string name = propertyName;
            string implName = propertyName + ImplementationPropertySuffix;
            string eventName = "On" + name;
            string fkBackingName = "_fk_" + name;
            string fkGuidBackingName = "_fk_guid_" + name;
            string referencedInterface = relEnd.Type.GetDataTypeString();
            string referencedImplementation = referencedInterface + ImplementationSuffix;
            string associationName = rel.GetAssociationName();
            string targetRoleName = otherEnd.RoleName;
            string positionPropertyName = rel.NeedsPositionStorage(endRole)
                ? name + Zetbox.API.Helper.PositionSuffix
                : null;
            string inverseNavigatorName = null; // do not care about inverse navigator
            bool inverseNavigatorIsList = false;
            bool eagerLoading = relEnd.Navigator != null && relEnd.Navigator.EagerLoading;
            bool relDataTypeExportable = rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable();
            bool callGetterSetterEvents = false;

            Properties.ObjectReferencePropertyTemplate.Call(Host,
                ctx,
                MembersToSerialize,
                moduleNamespace,
                ownInterface,
                name,
                implName,
                eventName,
                fkBackingName,
                fkGuidBackingName,
                referencedInterface,
                referencedImplementation,
                associationName,
                targetRoleName,
                positionPropertyName,
                inverseNavigatorName,
                inverseNavigatorIsList,
                eagerLoading,
                relDataTypeExportable,
                callGetterSetterEvents,
                false,
                false);
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:49,代码来源:RelationEntry.cs

示例5: 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

示例6: Do1_1_RelationChange_FromNullable_To_NotNullable

        public void Do1_1_RelationChange_FromNullable_To_NotNullable(Relation rel, RelationEndRole role)
        {
            RelationEnd relEnd = rel.GetEndFromRole(role);
            RelationEnd otherEnd = rel.GetOtherEndFromRole(role);

            var tblName = db.GetTableName(relEnd.Type.Module.SchemaName, relEnd.Type.TableName);
            var colName = Construct.ForeignKeyColumnName(otherEnd);

            db.AlterColumn(tblName, colName, System.Data.DbType.Int32, 0, 0, otherEnd.IsNullable(), null);
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:10,代码来源:Cases.cs

示例7: Call

        /// <summary>
        /// 
        /// </summary>
        /// <param name="host"></param>
        /// <param name="ctx"></param>
        /// <param name="serializationList"></param>
        /// <param name="name">the name of the property to create</param>
        /// <param name="wrapperClass">the name of the wrapper class for wrapping the EntityCollection</param>
        /// <param name="exposedListType">which generic interface to use for the collection (IList or ICollection)</param>
        /// <param name="rel"></param>
        /// <param name="endRole"></param>
        /// <param name="positionPropertyName">the name of the position property for this list</param>
        public static void Call(Arebis.CodeGeneration.IGenerationHost host,
            IZetboxContext ctx,
            Serialization.SerializationMembersList serializationList,
            string name,
            string wrapperClass,
            string exposedListType,
            Relation rel,
            RelationEndRole endRole,
            string positionPropertyName)
        {
            if (rel == null) { throw new ArgumentNullException("rel"); }

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

            string wrapperName = "_" + name;

            var otherName = otherEnd.Navigator == null ? relEnd.RoleName : otherEnd.Navigator.Name;

            string referencedInterface = otherEnd.Type.GetDataTypeString();

            Call(host, ctx, serializationList, name, wrapperName, wrapperClass, exposedListType, rel, endRole, positionPropertyName, otherName, referencedInterface);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:35,代码来源:ObjectListProperty.cs

示例8: Do_N_M_RelationChange_FromNotIndexed_To_Indexed

        public void Do_N_M_RelationChange_FromNotIndexed_To_Indexed(Relation rel, RelationEndRole role)
        {
            var savedRel = savedSchema.FindPersistenceObject<Relation>(rel.ExportGuid);

            if (!PreMigration(RelationMigrationEventType.ChangeHasPositionStorage, savedRel, rel))
                return;

            string assocName = rel.GetAssociationName();
            Log.InfoFormat("Create N:M Relation {1} PositionStorage: {0}", assocName, role);

            var tblName = db.GetTableName(rel.Module.SchemaName, rel.GetRelationTableName());
            var fkName = Construct.ForeignKeyColumnName(rel.GetEndFromRole(role));

            db.CreateColumn(tblName, fkName + Zetbox.API.Helper.PositionSuffix, System.Data.DbType.Int32, 0, 0, true);

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

示例9: Do_1_1_RelationChange_FromNullable_To_NotNullable

        public void Do_1_1_RelationChange_FromNullable_To_NotNullable(Relation rel, RelationEndRole role)
        {
            var savedRel = savedSchema.FindPersistenceObject<Relation>(rel.ExportGuid);

            if (!PreMigration(RelationMigrationEventType.ChangeToNotNullable, savedRel, rel))
                return;

            RelationEnd relEnd = rel.GetEndFromRole(role);
            RelationEnd otherEnd = rel.GetOtherEndFromRole(role);

            var tblName = relEnd.Type.GetTableRef(db);
            var colName = Construct.ForeignKeyColumnName(otherEnd);
            var idxName = Construct.IndexName(tblName.Name, colName);

            // MS SQL Server (and Postgres?) cannot alter columns when a index exists
            if (db.CheckIndexExists(tblName, idxName)) db.DropIndex(tblName, idxName);
            db.AlterColumn(tblName, colName, System.Data.DbType.Int32, 0, 0, otherEnd.IsNullable(), null);
            db.CreateIndex(tblName, idxName, false, false, colName);

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


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