Ejemplo n.º 1
0
        protected override void ApplyObjectReferencePropertyTemplate(ObjectReferenceProperty prop)
        {
            var rel = Zetbox.App.Extensions.RelationExtensions.Lookup(ctx, prop);

            // Navigator can be NULL
            // Debug.Assert(rel.A.Navigator.ID == prop.ID || rel.B.Navigator.ID == prop.ID);
            RelationEnd relEnd   = rel.GetEnd(prop);
            RelationEnd otherEnd = rel.GetOtherEnd(relEnd);

            if (rel.Storage == StorageType.Separate)
            {
                throw new InvalidOperationException("Separate Storage not implemented for ObjectReferenceProperty in 1:N");
            }

            this.WriteLine("    /*");
            RelationDebugTemplate.Call(Host, ctx, rel);
            this.WriteLine("    */");

            this.WriteLine("        // object reference property");
            Templates.Properties.ObjectReferencePropertyTemplate.Call(
                Host,
                ctx,
                this.MembersToSerialize,
                prop, true, true);
        }
Ejemplo n.º 2
0
        protected override void ApplyObjectReferenceListTemplate(ObjectReferenceProperty prop)
        {
            // TODO: move debugging output into Templates
            this.WriteLine("    /*");
            RelationDebugTemplate.Call(Host, ctx, Zetbox.App.Extensions.RelationExtensions.Lookup(ctx, prop));
            this.WriteLine("    */");

            var rel = RelationExtensions.Lookup(ctx, prop);

            var relEnd   = rel.GetEnd(prop);
            var otherEnd = rel.GetOtherEnd(relEnd);

            // without navigator, there should be no property
            if (relEnd.Navigator == null)
            {
                return;
            }

            switch ((StorageType)rel.Storage)
            {
            case StorageType.MergeIntoA:
            case StorageType.MergeIntoB:
            case StorageType.Replicate:
                // simple and direct reference
                this.WriteLine("        // object list property");
                base.ApplyObjectReferenceListTemplate(relEnd.Navigator as ObjectReferenceProperty);
                break;

            case StorageType.Separate:
                this.WriteLine("        // collection reference property");
                ApplyCollectionEntryListTemplate(rel, relEnd.GetRole());
                break;

            default:
                throw new NotImplementedException("unknown StorageHint for ObjectReferenceProperty[IsList == true]");
            }
        }
Ejemplo n.º 3
0
        public override void Generate()
        {
#line 32 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            this.WriteObjects("using System.Data.Metadata.Edm;\r\n");
            this.WriteObjects("using System.Data.Objects.DataClasses;\r\n");
            this.WriteObjects("using System.Xml;\r\n");
            this.WriteObjects("using System.Xml.Serialization;\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("using Zetbox.API;\r\n");
            this.WriteObjects("using Zetbox.DalProvider.Ef;\r\n");
            this.WriteObjects("\r\n");
#line 41 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            foreach (var rel in ctx.GetQuery <Relation>().ToList().OrderBy(r => r.GetAssociationName()))
            {
#line 44 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                this.WriteObjects("\r\n");
                this.WriteObjects("	/*\r\n");
#line 47 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                RelationDebugTemplate.Call(Host, ctx, rel);

#line 49 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                this.WriteObjects("	*/\r\n");
#line 51 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                switch (rel.Storage)
                {
                case StorageType.MergeIntoA:
                case StorageType.MergeIntoB:
                case StorageType.Replicate:

#line 57 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                    this.WriteObjects("\r\n");
                    this.WriteObjects("// basic association\r\n");
                    this.WriteObjects("[assembly: EdmRelationship(\r\n");
                    this.WriteObjects("    \"Model\", \"", rel.GetAssociationName(), "\",\r\n");
                    this.WriteObjects("    \"", rel.A.RoleName, "\", RelationshipMultiplicity.", rel.A.Multiplicity.ToCsdlRelationshipMultiplicity(), ", typeof(", rel.A.Type.GetDataTypeString() + ImplementationSuffix, "),\r\n");
                    this.WriteObjects("    \"", rel.B.RoleName, "\", RelationshipMultiplicity.", rel.B.Multiplicity.ToCsdlRelationshipMultiplicity(), ", typeof(", rel.B.Type.GetDataTypeString() + ImplementationSuffix, ")\r\n");
                    this.WriteObjects("    )]\r\n");
                    this.WriteObjects("\r\n");
#line 66 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                    break;

                case StorageType.Separate:

#line 69 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                    this.WriteObjects("\r\n");
                    this.WriteObjects("// The association from A to the CollectionEntry\r\n");
                    this.WriteObjects("[assembly: EdmRelationship(\"Model\", \"", rel.GetRelationAssociationName(RelationEndRole.A), "\",\r\n");
                    this.WriteObjects("    \"", rel.A.RoleName, "\", RelationshipMultiplicity.ZeroOrOne, typeof(", rel.A.Type.GetDataTypeString() + ImplementationSuffix, "),\r\n");
                    this.WriteObjects("    \"CollectionEntry\", RelationshipMultiplicity.Many, typeof(", rel.GetRelationFullName() + ImplementationSuffix, ")\r\n");
                    this.WriteObjects("    )]\r\n");
                    this.WriteObjects("// The association from B to the CollectionEntry\r\n");
                    this.WriteObjects("[assembly: EdmRelationship(\"Model\", \"", rel.GetRelationAssociationName(RelationEndRole.B), "\",\r\n");
                    this.WriteObjects("    \"", rel.B.RoleName, "\", RelationshipMultiplicity.ZeroOrOne, typeof(", rel.B.Type.GetDataTypeString() + ImplementationSuffix, "),\r\n");
                    this.WriteObjects("    \"CollectionEntry\", RelationshipMultiplicity.Many, typeof(", rel.GetRelationFullName() + ImplementationSuffix, ")\r\n");
                    this.WriteObjects("    )]\r\n");
#line 81 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                    break;

                default:
                    throw new NotImplementedException(String.Format("Unknown StorageHint.{0} preference", rel.Storage));
                }
            }


#line 88 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            this.WriteObjects("\r\n");
#line 90 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            foreach (var prop in ctx.GetQuery <ValueTypeProperty>()
                     .Where(p => p.IsList && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
#line 97 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                this.WriteObjects("\r\n");
                this.WriteObjects("// object-value association\r\n");
                this.WriteObjects("[assembly: EdmRelationship(\r\n");
                this.WriteObjects("    \"Model\", \"", prop.GetAssociationName(), "\",\r\n");
                this.WriteObjects("    \"", prop.ObjectClass.Name, "\", RelationshipMultiplicity.ZeroOrOne, typeof(", prop.ObjectClass.Module.Namespace + "." + prop.ObjectClass.Name + ImplementationSuffix, "),\r\n");
                this.WriteObjects("    \"CollectionEntry\", RelationshipMultiplicity.Many, typeof(", prop.GetCollectionEntryFullName() + ImplementationSuffix, ")\r\n");
                this.WriteObjects("    )]\r\n");
                this.WriteObjects("\r\n");
#line 106 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            }

#line 108 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            this.WriteObjects("\r\n");
#line 110 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            foreach (var prop in ctx.GetQuery <CompoundObjectProperty>()
                     .Where(p => p.IsList) // && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
#line 117 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                this.WriteObjects("\r\n");
                this.WriteObjects("// object-struct association\r\n");
                this.WriteObjects("[assembly: EdmRelationship(\r\n");
                this.WriteObjects("    \"Model\", \"", prop.GetAssociationName(), "\",\r\n");
                this.WriteObjects("    \"", prop.ObjectClass.Name, "\", RelationshipMultiplicity.ZeroOrOne, typeof(", prop.ObjectClass.Module.Namespace + "." + prop.ObjectClass.Name + ImplementationSuffix, "),\r\n");
                this.WriteObjects("    \"CollectionEntry\", RelationshipMultiplicity.Many, typeof(", prop.GetCollectionEntryFullName() + ImplementationSuffix, ")\r\n");
                this.WriteObjects("    )]\r\n");
                this.WriteObjects("\r\n");
#line 126 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            }

#line 128 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            this.WriteObjects("\r\n");
#line 130 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
            foreach (var cls in ctx.GetQuery <ObjectClass>().Where(c => c.BaseObjectClass == null)
                     .OrderBy(c => c.Name))
            {
                if (cls.NeedsRightsTable())
                {
#line 136 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                    this.WriteObjects("[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute(\"Model\", \"", Construct.SecurityRulesFKName(cls), "\", \r\n");
                    this.WriteObjects("	\"", cls.Name, "\", \r\n");
                    this.WriteObjects("	global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, \r\n");
                    this.WriteObjects("	typeof(", cls.Module.Namespace + "." + cls.Name + ImplementationSuffix, "), \r\n");
                    this.WriteObjects("	\"", Construct.SecurityRulesClassName(cls), "\", \r\n");
                    this.WriteObjects("	global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, \r\n");
                    this.WriteObjects("	typeof(", cls.Module.Namespace + "." + Construct.SecurityRulesClassName(cls) + ImplementationSuffix, "))]\r\n");
#line 144 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\ObjectClasses\AssociationSetAttributes.cst"
                }
            }
        }
Ejemplo n.º 4
0
        public override void Generate()
        {
#line 31 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
            this.WriteObjects("<Schema Namespace=\"Model\" Alias=\"Self\" xmlns=\"http://schemas.microsoft.com/ado/2006/04/edm\">\r\n");
            this.WriteObjects("  <EntityContainer Name=\"Entities\">\r\n");
            this.WriteObjects("  \r\n");
            this.WriteObjects("    <!-- EntitySets for all classes -->\r\n");
#line 37 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var cls in ctx.GetBaseClasses().OrderBy(c => c.Name))
            {
#line 40 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", cls.Name, "\" EntityType=\"Model.", cls.Name, "\" />\r\n");
#line 42 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (cls.NeedsRightsTable())
                {
#line 45 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("    <EntitySet Name=\"", Construct.SecurityRulesClassName(cls), "\" EntityType=\"Model.", Construct.SecurityRulesClassName(cls), "\" />\r\n");
                    this.WriteObjects("    <AssociationSet Name=\"", Construct.SecurityRulesFKName(cls), "\" Association=\"Model.", Construct.SecurityRulesFKName(cls), "\">\r\n");
                    this.WriteObjects("      <End Role=\"", cls.Name, "\" EntitySet=\"", cls.Name, "\" />\r\n");
                    this.WriteObjects("      <End Role=\"", Construct.SecurityRulesClassName(cls), "\" EntitySet=\"", Construct.SecurityRulesClassName(cls), "\" />\r\n");
                    this.WriteObjects("    </AssociationSet>\r\n");
#line 51 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }
            }

#line 54 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("    <!-- EntitySets and AssociationSets for all object-object CollectionEntrys -->\r\n");
#line 56 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var rel in ctx.GetRelationsWithSeparateStorage())
            {
                string entityName = rel.GetRelationClassName();
                string assocNameA = rel.GetRelationAssociationName(RelationEndRole.A);
                string assocNameB = rel.GetRelationAssociationName(RelationEndRole.B);

#line 62 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", entityName, "\" EntityType=\"Model.", entityName, "\" />\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocNameA, "\" Association=\"Model.", assocNameA, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", rel.A.RoleName, "\" EntitySet=\"", rel.A.Type.GetRootClass().Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", entityName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocNameB, "\" Association=\"Model.", assocNameB, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", rel.B.RoleName, "\" EntitySet=\"", rel.B.Type.GetRootClass().Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", entityName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
#line 72 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 74 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets and AssociationSets for all object-value CollectionEntrys -->\r\n");
#line 77 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var prop in ctx.GetQuery <ValueTypeProperty>()
                     .Where(p => p.IsList && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
                string assocName  = prop.GetAssociationName();
                string entityName = prop.GetCollectionEntryClassName();

#line 86 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", entityName, "\" EntityType=\"Model.", entityName, "\" />\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocName, "\" Association=\"Model.", assocName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", prop.ObjectClass.Name, "\" EntitySet=\"", ((ObjectClass)prop.ObjectClass).GetRootClass().Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", entityName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
#line 92 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 94 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets and AssociationSets for all object-struct CollectionEntrys -->\r\n");
#line 97 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var prop in ctx.GetQuery <CompoundObjectProperty>()
                     .Where(p => p.IsList) // && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
                string assocName  = prop.GetAssociationName();
                string entityName = prop.GetCollectionEntryClassName();

#line 106 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", entityName, "\" EntityType=\"Model.", entityName, "\" />\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocName, "\" Association=\"Model.", assocName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", prop.ObjectClass.Name, "\" EntitySet=\"", ((ObjectClass)prop.ObjectClass).GetRootClass().Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", entityName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
#line 112 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 114 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- AssociationSets for all object-object relations without CollectionEntrys -->\r\n");
#line 117 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var rel in ctx.GetRelationsWithoutSeparateStorage())
            {
                string assocName = rel.GetAssociationName();

#line 121 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("    <AssociationSet Name=\"", assocName, "\" Association=\"Model.", assocName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", rel.A.RoleName, "\" EntitySet=\"", rel.A.Type.GetRootClass().Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"", rel.B.RoleName, "\" EntitySet=\"", rel.B.Type.GetRootClass().Name, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
#line 126 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 128 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <FunctionImport Name=\"GetContinuousSequenceNumber\" ReturnType=\"Collection(Int32)\">\r\n");
            this.WriteObjects("      <Parameter Name=\"seqNumber\" Mode=\"In\" Type=\"Guid\" />\r\n");
            this.WriteObjects("      <Parameter Name=\"result\" Mode=\"Out\" Type=\"Int32\" />\r\n");
            this.WriteObjects("    </FunctionImport>\r\n");
            this.WriteObjects("    <FunctionImport Name=\"GetSequenceNumber\" ReturnType=\"Collection(Int32)\">\r\n");
            this.WriteObjects("      <Parameter Name=\"seqNumber\" Mode=\"In\" Type=\"Guid\" />\r\n");
            this.WriteObjects("      <Parameter Name=\"result\" Mode=\"Out\" Type=\"Int32\" />\r\n");
            this.WriteObjects("    </FunctionImport>\r\n");
            this.WriteObjects("  </EntityContainer>\r\n");
            this.WriteObjects("  \r\n");
            this.WriteObjects("  <!-- EntityTypes for all base classes -->\r\n");
#line 141 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var cls in ctx.GetBaseClasses().OrderBy(c => c.Name))
            {
#line 144 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <EntityType Name=\"", cls.Name, "\"", GetAbstractModifier(cls), ">\r\n");
                this.WriteObjects("    <Key>\r\n");
                this.WriteObjects("      <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("    </Key>\r\n");
                this.WriteObjects("    <Property Name=\"ID\" Type=\"Int32\" Nullable=\"false\" />\r\n");
#line 150 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                ApplyEntityTypeFieldDefs(cls.Properties.Cast <Property>());
                if (cls.NeedsRightsTable())
                {
#line 154 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("    <NavigationProperty Name=\"SecurityRightsCollection", ImplementationPropertySuffix, "\" Relationship=\"Model.", Construct.SecurityRulesFKName(cls), "\" FromRole=\"", cls.Name, "\" ToRole=\"", Construct.SecurityRulesClassName(cls), "\" />\r\n");
#line 156 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }

#line 158 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
#line 160 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (cls.NeedsRightsTable())
                {
#line 163 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("  <EntityType Name=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("    <Key>\r\n");
                    this.WriteObjects("	  <PropertyRef Name=\"ID\" />\r\n");
                    this.WriteObjects("	  <PropertyRef Name=\"Identity\" />\r\n");
                    this.WriteObjects("    </Key>\r\n");
                    this.WriteObjects("    <Property Name=\"ID\" Type=\"Int32\" Nullable=\"false\" />\r\n");
                    this.WriteObjects("    <Property Name=\"Identity\" Type=\"Int32\" Nullable=\"false\" />\r\n");
                    this.WriteObjects("    <Property Name=\"Right\" Type=\"Int32\" Nullable=\"false\" />\r\n");
                    this.WriteObjects("  </EntityType>\r\n");
                    this.WriteObjects("  <Association Name=\"", Construct.SecurityRulesFKName(cls), "\">\r\n");
                    this.WriteObjects("    <End Role=\"", cls.Name, "\" Type=\"Model.", cls.Name, "\" Multiplicity=\"1\" />\r\n");
                    this.WriteObjects("    <End Role=\"", Construct.SecurityRulesClassName(cls), "\" Type=\"Model.", Construct.SecurityRulesClassName(cls), "\" Multiplicity=\"*\" />\r\n");
                    this.WriteObjects("    <ReferentialConstraint>\r\n");
                    this.WriteObjects("	  <Principal Role=\"", cls.Name, "\">\r\n");
                    this.WriteObjects("	    <PropertyRef Name=\"ID\" />\r\n");
                    this.WriteObjects("	  </Principal>\r\n");
                    this.WriteObjects("	  <Dependent Role=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("	    <PropertyRef Name=\"ID\" />\r\n");
                    this.WriteObjects("	  </Dependent>\r\n");
                    this.WriteObjects("    </ReferentialConstraint>\r\n");
                    this.WriteObjects("  </Association>\r\n");
#line 185 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }
            }

#line 188 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- EntityTypes for all other classes -->\r\n");
#line 191 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var cls in ctx.GetDerivedClasses().OrderBy(c => c.Name))
            {
#line 194 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <EntityType Name=\"", cls.Name, "\" BaseType=\"Model.", cls.BaseObjectClass.Name, "\"", GetAbstractModifier(cls), ">\r\n");
#line 195 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                ApplyEntityTypeFieldDefs(cls.Properties.Cast <Property>());
#line 196 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
#line 198 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 200 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- EntityTypes and Associations for all object-object CollectionEntrys -->\r\n");
#line 203 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var rel in ctx.GetRelationsWithSeparateStorage())
            {
#line 207 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <!--\r\n");
#line 209 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                RelationDebugTemplate.Call(Host, ctx, rel);

#line 211 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  -->\r\n");
                this.WriteObjects("  <EntityType Name=\"", rel.GetRelationClassName(), "\" >\r\n");
                this.WriteObjects("    <Key>\r\n");
                this.WriteObjects("      <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("    </Key>\r\n");
                this.WriteObjects("    <Property Name=\"ID\" Type=\"Int32\" Nullable=\"false\" />\r\n");
#line 218 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable())
                {
#line 221 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("	<Property Name=\"ExportGuid\" Type=\"Guid\" Nullable=\"false\" />\r\n");
#line 223 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }

#line 224 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("	\r\n");
                this.WriteObjects("    \r\n");
                this.WriteObjects("    <!-- A -->\r\n");
                this.WriteObjects("    <NavigationProperty Name=\"A", ImplementationPropertySuffix, "\"\r\n");
                this.WriteObjects("                        Relationship=\"Model.", rel.GetRelationAssociationName(RelationEndRole.A), "\"\r\n");
                this.WriteObjects("                        FromRole=\"CollectionEntry\"\r\n");
                this.WriteObjects("                        ToRole=\"", rel.A.RoleName, "\" />\r\n");
#line 232 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (rel.NeedsPositionStorage(RelationEndRole.A))
                {
#line 235 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("    <Property Name=\"A", Zetbox.API.Helper.PositionSuffix, "\" Type=\"Int32\" Nullable=\"false\" />\r\n");
#line 237 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }

#line 239 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("\r\n");
                this.WriteObjects("    <!-- B -->\r\n");
                this.WriteObjects("    <NavigationProperty Name=\"B", ImplementationPropertySuffix, "\"\r\n");
                this.WriteObjects("                        Relationship=\"Model.", rel.GetRelationAssociationName(RelationEndRole.B), "\"\r\n");
                this.WriteObjects("                        FromRole=\"CollectionEntry\"\r\n");
                this.WriteObjects("                        ToRole=\"", rel.B.RoleName, "\" />\r\n");
#line 246 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (rel.NeedsPositionStorage(RelationEndRole.B))
                {
#line 249 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("    <Property Name=\"B", Zetbox.API.Helper.PositionSuffix, "\" Type=\"Int32\" Nullable=\"false\" />\r\n");
#line 251 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }

#line 253 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
                this.WriteObjects("  <Association Name=\"", rel.GetRelationAssociationName(RelationEndRole.A), "\" >\r\n");
                this.WriteObjects("    <End Role=\"", rel.A.RoleName, "\"\r\n");
                this.WriteObjects("         Type=\"Model.", rel.A.Type.Name, "\" \r\n");
                this.WriteObjects("         Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <End Role=\"CollectionEntry\"\r\n");
                this.WriteObjects("         Type=\"Model.", rel.GetRelationClassName(), "\"\r\n");
                this.WriteObjects("         Multiplicity=\"*\" />\r\n");
                this.WriteObjects("  </Association>\r\n");
                this.WriteObjects("  <Association Name=\"", rel.GetRelationAssociationName(RelationEndRole.B), "\" >\r\n");
                this.WriteObjects("    <End Role=\"", rel.B.RoleName, "\"\r\n");
                this.WriteObjects("         Type=\"Model.", rel.B.Type.Name, "\" \r\n");
                this.WriteObjects("         Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <End Role=\"CollectionEntry\"\r\n");
                this.WriteObjects("         Type=\"Model.", rel.GetRelationClassName(), "\"\r\n");
                this.WriteObjects("         Multiplicity=\"*\" />\r\n");
                this.WriteObjects("  </Association>\r\n");
                this.WriteObjects("  \r\n");
#line 272 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 274 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- EntityTypes and Associations for all object-value CollectionEntrys -->\r\n");
#line 278 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var prop in ctx.GetQuery <ValueTypeProperty>()
                     .Where(p => p.IsList && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
#line 286 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <!-- ", prop.ObjectClass.Name, ".", prop.Name, " -->\r\n");
                this.WriteObjects("  <EntityType Name=\"", prop.GetCollectionEntryClassName(), "\" >\r\n");
                this.WriteObjects("    <Key>\r\n");
                this.WriteObjects("      <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("    </Key>\r\n");
                this.WriteObjects("    <Property Name=\"ID\" Type=\"Int32\" Nullable=\"false\" />\r\n");
                this.WriteObjects("    \r\n");
                this.WriteObjects("    <!-- A -->\r\n");
                this.WriteObjects("    <NavigationProperty Name=\"Parent", ImplementationPropertySuffix, "\"\r\n");
                this.WriteObjects("                        Relationship=\"Model.", prop.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                        FromRole=\"CollectionEntry\"\r\n");
                this.WriteObjects("                        ToRole=\"", prop.ObjectClass.Name, "\" />\r\n");
                this.WriteObjects("    <!-- B -->\r\n");
                this.WriteObjects("    ", PlainPropertyDefinitionFromValueType(prop, "Value", ImplementationPropertySuffix), "\r\n");
#line 301 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (prop.HasPersistentOrder)
                {
#line 304 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("    <Property Name=\"Value", Zetbox.API.Helper.PositionSuffix, "\" Type=\"Int32\" Nullable=\"false\" />\r\n");
#line 306 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }

#line 308 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
                this.WriteObjects("  <Association Name=\"", prop.GetAssociationName(), "\" >\r\n");
                this.WriteObjects("    <End Role=\"", prop.ObjectClass.Name, "\"\r\n");
                this.WriteObjects("         Type=\"Model.", prop.ObjectClass.Name, "\" \r\n");
                this.WriteObjects("         Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <End Role=\"CollectionEntry\"\r\n");
                this.WriteObjects("         Type=\"Model.", prop.GetCollectionEntryClassName(), "\" \r\n");
                this.WriteObjects("         Multiplicity=\"*\" />\r\n");
                this.WriteObjects("  </Association>\r\n");
#line 318 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 320 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("<!-- EntityTypes and Associations for all object-CompoundObject CollectionEntrys -->\r\n");
#line 323 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var prop in ctx.GetQuery <CompoundObjectProperty>()
                     .Where(p => p.IsList) // && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
#line 331 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <!-- ", prop.ObjectClass.Name, ".", prop.Name, " -->\r\n");
                this.WriteObjects("  <EntityType Name=\"", prop.GetCollectionEntryClassName(), "\" >\r\n");
                this.WriteObjects("    <Key>\r\n");
                this.WriteObjects("      <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("    </Key>\r\n");
                this.WriteObjects("    <Property Name=\"ID\" Type=\"Int32\" Nullable=\"false\" />\r\n");
                this.WriteObjects("    \r\n");
                this.WriteObjects("    <!-- A -->\r\n");
                this.WriteObjects("    <NavigationProperty Name=\"Parent", ImplementationPropertySuffix, "\"\r\n");
                this.WriteObjects("                        Relationship=\"Model.", prop.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                        FromRole=\"CollectionEntry\"\r\n");
                this.WriteObjects("                        ToRole=\"", prop.ObjectClass.Name, "\" />\r\n");
                this.WriteObjects("    <!-- B -->\r\n");
                this.WriteObjects("    <Property Name=\"Value", ImplementationPropertySuffix, "\"\r\n");
                this.WriteObjects("              Type=\"Model.", prop.CompoundObjectDefinition.Name, "\"\r\n");
                this.WriteObjects("              Nullable=\"false\" />\r\n");
#line 348 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                if (prop.HasPersistentOrder)
                {
#line 351 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                    this.WriteObjects("    <Property Name=\"B", Zetbox.API.Helper.PositionSuffix, "\" Type=\"Int32\" Nullable=\"false\" />\r\n");
#line 353 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                }

#line 355 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
                this.WriteObjects("  <Association Name=\"", prop.GetAssociationName(), "\" >\r\n");
                this.WriteObjects("    <End Role=\"", prop.ObjectClass.Name, "\"\r\n");
                this.WriteObjects("         Type=\"Model.", prop.ObjectClass.Name, "\" \r\n");
                this.WriteObjects("         Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <End Role=\"CollectionEntry\"\r\n");
                this.WriteObjects("         Type=\"Model.", prop.GetCollectionEntryClassName(), "\" \r\n");
                this.WriteObjects("         Multiplicity=\"*\" />\r\n");
                this.WriteObjects("  </Association>\r\n");
#line 365 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 367 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- Associations for all object-object relations without CollectionEntrys -->\r\n");
#line 370 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var rel in ctx.GetRelationsWithoutSeparateStorage())
            {
#line 373 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <Association Name=\"", rel.GetAssociationName(), "\" >\r\n");
                this.WriteObjects("    <End Role=\"", rel.A.RoleName, "\"\r\n");
                this.WriteObjects("         Type=\"Model.", rel.A.Type.Name, "\" \r\n");
                this.WriteObjects("         Multiplicity=\"", rel.A.Multiplicity.ToCsdlRelationshipMultiplicity().ToXmlValue(), "\" />\r\n");
                this.WriteObjects("    <End Role=\"", rel.B.RoleName, "\"\r\n");
                this.WriteObjects("         Type=\"Model.", rel.B.Type.Name, "\" \r\n");
                this.WriteObjects("         Multiplicity=\"", rel.B.Multiplicity.ToCsdlRelationshipMultiplicity().ToXmlValue(), "\" />\r\n");
                this.WriteObjects("  </Association>\r\n");
#line 382 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }

#line 384 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- ComplexTypes for all CompoundObjects -->\r\n");
#line 388 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            foreach (var cls in ctx.GetQuery <CompoundObject>().OrderBy(s => s.Name))
            {
#line 391 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  <ComplexType Name=\"", cls.Name, "\" >\r\n");
#line 392 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                ApplyEntityTypeFieldDefs(cls.Properties.Cast <Property>());
#line 393 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
                this.WriteObjects("  </ComplexType>\r\n");
#line 394 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            }


#line 397 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.csdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("</Schema>\r\n");
        }
Ejemplo n.º 5
0
        public override void Generate()
        {
#line 31 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            this.WriteObjects("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
            this.WriteObjects("<Mapping Space=\"C-S\" xmlns=\"urn:schemas-microsoft-com:windows:storage:mapping:CS\">\r\n");
            this.WriteObjects("  <EntityContainerMapping StorageEntityContainer=\"dbo\" CdmEntityContainer=\"Entities\">\r\n");
            this.WriteObjects("    \r\n");
            this.WriteObjects("    <!-- EntitySetMappings for classes -->\r\n");
#line 37 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            foreach (var cls in ctx.GetBaseClasses().OrderBy(c => c.Name))
            {
#line 40 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    <EntitySetMapping Name=\"", cls.Name, "\">\r\n");
#line 41 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                ApplyEntityTypeMapping(cls);
#line 42 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    </EntitySetMapping>\r\n");
#line 44 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                if (cls.NeedsRightsTable())
                {
#line 47 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                    this.WriteObjects("    <EntitySetMapping Name=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("      <EntityTypeMapping TypeName=\"IsTypeOf(Model.", Construct.SecurityRulesClassName(cls), ")\">\r\n");
                    this.WriteObjects("        <MappingFragment StoreEntitySet=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("          <ScalarProperty Name=\"ID\" ColumnName=\"ID\" />\r\n");
                    this.WriteObjects("          <ScalarProperty Name=\"Identity\" ColumnName=\"Identity\" />\r\n");
                    this.WriteObjects("          <ScalarProperty Name=\"Right\" ColumnName=\"Right\" />\r\n");
                    this.WriteObjects("        </MappingFragment>\r\n");
                    this.WriteObjects("      </EntityTypeMapping>\r\n");
                    this.WriteObjects("    </EntitySetMapping>\r\n");
                    this.WriteObjects("    <AssociationSetMapping Name=\"", Construct.SecurityRulesFKName(cls), "\" TypeName=\"Model.", Construct.SecurityRulesFKName(cls), "\" StoreEntitySet=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("      <EndProperty Name=\"", cls.Name, "\">\r\n");
                    this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\" />\r\n");
                    this.WriteObjects("      </EndProperty>\r\n");
                    this.WriteObjects("      <EndProperty Name=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\" />\r\n");
                    this.WriteObjects("        <ScalarProperty Name=\"Identity\" ColumnName=\"Identity\" />\r\n");
                    this.WriteObjects("      </EndProperty>\r\n");
                    this.WriteObjects("    </AssociationSetMapping>\r\n");
#line 66 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                }
            }

#line 69 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySetMappings and AssociationSetMappings for object-object relations with a CollectionEntry -->\r\n");
#line 73 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            foreach (var rel in ctx.GetRelationsWithSeparateStorage())
            {
                string fkAName = rel.GetRelationFkColumnName(RelationEndRole.A);
                string fkBName = rel.GetRelationFkColumnName(RelationEndRole.B);

#line 78 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    <!--\r\n");
#line 80 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                RelationDebugTemplate.Call(Host, ctx, rel);

#line 82 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    -->\r\n");
                this.WriteObjects("    <EntitySetMapping Name=\"", rel.GetRelationClassName(), "\">\r\n");
                this.WriteObjects("      <EntityTypeMapping TypeName=\"IsTypeOf(Model.", rel.GetRelationClassName(), ")\">\r\n");
                this.WriteObjects("        <MappingFragment StoreEntitySet=\"", rel.GetRelationClassName(), "\">\r\n");
                this.WriteObjects("          <ScalarProperty Name=\"ID\" ColumnName=\"ID\" />\r\n");
#line 88 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                if (rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable())
                {
#line 91 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                    this.WriteObjects("		  <ScalarProperty Name=\"ExportGuid\" ColumnName=\"ExportGuid\" />\r\n");
#line 93 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                }
                if (rel.NeedsPositionStorage(RelationEndRole.A))
                {
#line 97 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                    this.WriteObjects("          <ScalarProperty Name=\"A", Zetbox.API.Helper.PositionSuffix, "\" ColumnName=\"", fkAName, "", Zetbox.API.Helper.PositionSuffix, "\" />\r\n");
#line 99 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                }

                if (rel.NeedsPositionStorage(RelationEndRole.B))
                {
#line 104 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                    this.WriteObjects("          <ScalarProperty Name=\"B", Zetbox.API.Helper.PositionSuffix, "\" ColumnName=\"", fkBName, "", Zetbox.API.Helper.PositionSuffix, "\" />\r\n");
#line 106 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                }

#line 108 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("        </MappingFragment>\r\n");
                this.WriteObjects("      </EntityTypeMapping>\r\n");
                this.WriteObjects("    </EntitySetMapping>\r\n");
                this.WriteObjects("    <!-- A to CollectionEntry -->\r\n");
                this.WriteObjects("    <AssociationSetMapping Name=\"", rel.GetRelationAssociationName(RelationEndRole.A), "\"\r\n");
                this.WriteObjects("                           TypeName=\"Model.", rel.GetRelationAssociationName(RelationEndRole.A), "\"\r\n");
                this.WriteObjects("                           StoreEntitySet=\"", rel.GetRelationClassName(), "\" >\r\n");
                this.WriteObjects("      <EndProperty Name=\"", rel.A.RoleName, "\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"", fkAName, "\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <EndProperty Name=\"CollectionEntry\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <Condition ColumnName=\"", fkAName, "\" IsNull=\"false\"/>\r\n");
                this.WriteObjects("    </AssociationSetMapping>\r\n");
                this.WriteObjects("    <!-- B to CollectionEntry -->\r\n");
                this.WriteObjects("    <AssociationSetMapping Name=\"", rel.GetRelationAssociationName(RelationEndRole.B), "\"\r\n");
                this.WriteObjects("                           TypeName=\"Model.", rel.GetRelationAssociationName(RelationEndRole.B), "\"\r\n");
                this.WriteObjects("                           StoreEntitySet=\"", rel.GetRelationClassName(), "\" >\r\n");
                this.WriteObjects("      <EndProperty Name=\"", rel.B.RoleName, "\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"", fkBName, "\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <EndProperty Name=\"CollectionEntry\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <Condition ColumnName=\"", fkBName, "\" IsNull=\"false\"/>\r\n");
                this.WriteObjects("    </AssociationSetMapping>\r\n");
                this.WriteObjects("\r\n");
#line 137 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            }


#line 140 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- AssociationSetMappings for direct object-object relations without a CollectionEntry -->\r\n");
#line 144 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            foreach (var rel in ctx.GetRelationsWithoutSeparateStorage())
            {
                RelationEnd principal, dependent;

                switch (rel.Storage)
                {
                case StorageType.MergeIntoA:
                    principal = rel.B;
                    dependent = rel.A;
                    break;

                case StorageType.MergeIntoB:
                    principal = rel.A;
                    dependent = rel.B;
                    break;

                default:
                    throw new NotImplementedException();
                }

#line 162 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    <!--\r\n");
#line 164 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                RelationDebugTemplate.Call(Host, ctx, rel);

#line 166 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    -->\r\n");
                this.WriteObjects("    <AssociationSetMapping Name=\"", rel.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                           TypeName=\"Model.", rel.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                           StoreEntitySet=\"", dependent.Type.Name, "\" >\r\n");
                this.WriteObjects("      <EndProperty Name=\"", principal.RoleName, "\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"fk_", principal.RoleName, "\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <EndProperty Name=\"", dependent.RoleName, "\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <Condition ColumnName=\"fk_", principal.RoleName, "\" IsNull=\"false\"/>\r\n");
                this.WriteObjects("    </AssociationSetMapping>\r\n");
#line 179 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            }


#line 182 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySetMappings and AssociationSetMappings for object-value CollectionEntrys -->\r\n");
#line 185 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            foreach (var prop in ctx.GetQuery <ValueTypeProperty>()
                     .Where(p => p.IsList && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
#line 192 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    <EntitySetMapping Name=\"", prop.GetCollectionEntryClassName(), "\">\r\n");
                this.WriteObjects("      <EntityTypeMapping TypeName=\"IsTypeOf(Model.", prop.GetCollectionEntryClassName(), ")\">\r\n");
                this.WriteObjects("        <MappingFragment StoreEntitySet=\"", prop.GetCollectionEntryClassName(), "\">\r\n");
                this.WriteObjects("          <ScalarProperty Name=\"ID\" ColumnName=\"ID\" />\r\n");
                this.WriteObjects("          <ScalarProperty Name=\"Value\" ColumnName=\"", prop.Name, "\" />\r\n");
#line 198 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                if (prop.HasPersistentOrder)
                {
#line 201 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                    this.WriteObjects("          <ScalarProperty Name=\"B", Zetbox.API.Helper.PositionSuffix, "\" ColumnName=\"BIndex\" />\r\n");
#line 203 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                }

#line 205 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("        </MappingFragment>\r\n");
                this.WriteObjects("      </EntityTypeMapping>\r\n");
                this.WriteObjects("    </EntitySetMapping>\r\n");
                this.WriteObjects("    <AssociationSetMapping Name=\"", prop.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                           TypeName=\"Model.", prop.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                           StoreEntitySet=\"", prop.GetCollectionEntryClassName(), "\" >\r\n");
                this.WriteObjects("      <EndProperty Name=\"", prop.ObjectClass.Name, "\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"fk_", prop.ObjectClass.Name, "\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <EndProperty Name=\"CollectionEntry\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <Condition ColumnName=\"fk_", prop.ObjectClass.Name, "\" IsNull=\"false\"/>\r\n");
                this.WriteObjects("    </AssociationSetMapping>\r\n");
#line 220 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            }


#line 223 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySetMappings and AssociationSetMappings for object-struct CollectionEntrys -->\r\n");
#line 226 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            foreach (var prop in ctx.GetQuery <CompoundObjectProperty>()
                     .Where(p => p.IsList) // && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
#line 233 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("    <EntitySetMapping Name=\"", prop.GetCollectionEntryClassName(), "\">\r\n");
                this.WriteObjects("      <EntityTypeMapping TypeName=\"IsTypeOf(Model.", prop.GetCollectionEntryClassName(), ")\">\r\n");
                this.WriteObjects("        <MappingFragment StoreEntitySet=\"", prop.GetCollectionEntryClassName(), "\">\r\n");
                this.WriteObjects("          <ScalarProperty Name=\"ID\" ColumnName=\"ID\" />\r\n");
                this.WriteObjects("          ");
#line 237 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                ModelMslEntityTypeMappingComplexProperty.Call(Host, ctx, prop, "Value", string.Empty);
#line 239 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                if (prop.HasPersistentOrder)
                {
#line 242 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                    this.WriteObjects("          <ScalarProperty Name=\"Value", Zetbox.API.Helper.PositionSuffix, "\" ColumnName=\"BIndex\" />\r\n");
#line 244 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                }

#line 246 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
                this.WriteObjects("        </MappingFragment>\r\n");
                this.WriteObjects("      </EntityTypeMapping>\r\n");
                this.WriteObjects("    </EntitySetMapping>\r\n");
                this.WriteObjects("    <AssociationSetMapping Name=\"", prop.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                           TypeName=\"Model.", prop.GetAssociationName(), "\"\r\n");
                this.WriteObjects("                           StoreEntitySet=\"", prop.GetCollectionEntryClassName(), "\" >\r\n");
                this.WriteObjects("      <EndProperty Name=\"", prop.ObjectClass.Name, "\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"fk_", prop.ObjectClass.Name, "\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <EndProperty Name=\"CollectionEntry\">\r\n");
                this.WriteObjects("        <ScalarProperty Name=\"ID\" ColumnName=\"ID\"/>\r\n");
                this.WriteObjects("      </EndProperty>\r\n");
                this.WriteObjects("      <Condition ColumnName=\"fk_", prop.ObjectClass.Name, "\" IsNull=\"false\"/>\r\n");
                this.WriteObjects("    </AssociationSetMapping>\r\n");
#line 261 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            }


#line 264 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.msl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("	<FunctionImportMapping FunctionImportName=\"GetContinuousSequenceNumber\" FunctionName=\"Model.Store.GetContinuousSequenceNumber\" />\r\n");
            this.WriteObjects("    <FunctionImportMapping FunctionImportName=\"GetSequenceNumber\" FunctionName=\"Model.Store.GetSequenceNumber\" />\r\n");
            this.WriteObjects("  </EntityContainerMapping>\r\n");
            this.WriteObjects("</Mapping>");
        }
Ejemplo n.º 6
0
        public override void Generate()
        {
#line 33 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
            this.WriteObjects("<Schema xmlns=\"http://schemas.microsoft.com/ado/2006/04/edm/ssdl\"\r\n");
            this.WriteObjects("        Namespace=\"Model.Store\"\r\n");
            this.WriteObjects("        Alias=\"Self\"\r\n");
            this.WriteObjects("        Provider=\"", schemaProvider.AdoNetProvider, "\"\r\n");
            this.WriteObjects("        ProviderManifestToken=\"", schemaProvider.ManifestToken, "\" >\r\n");
            this.WriteObjects("  <EntityContainer Name=\"dbo\">\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets for all Base Classes -->\r\n");
#line 43 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var cls in ctx.GetBaseClasses().OrderBy(c => c.Name))
            {
#line 46 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", cls.Name, "\" EntityType=\"Model.Store.", cls.Name, "\" Schema=\"", cls.Module.SchemaName, "\" Table=\"", cls.TableName, "\"/>\r\n");
#line 48 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (cls.NeedsRightsTable())
                {
#line 51 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("    <EntitySet Name=\"", Construct.SecurityRulesClassName(cls), "\" EntityType=\"Model.Store.", Construct.SecurityRulesClassName(cls), "\" Schema=\"", cls.Module.SchemaName, "\" Table=\"", Construct.SecurityRulesTableName(cls), "\"/>\r\n");
                    this.WriteObjects("    <AssociationSet Name=\"", Construct.SecurityRulesFKName(cls), "\" Association=\"Model.Store.", Construct.SecurityRulesFKName(cls), "\">\r\n");
                    this.WriteObjects("      <End Role=\"", cls.Name, "\" EntitySet=\"", cls.Name, "\" />\r\n");
                    this.WriteObjects("      <End Role=\"", Construct.SecurityRulesClassName(cls), "\" EntitySet=\"", Construct.SecurityRulesClassName(cls), "\" />\r\n");
                    this.WriteObjects("    </AssociationSet>\r\n");
#line 57 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }
            }

#line 60 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets for all derived classes and their inheritance AssociationSets -->\r\n");
#line 63 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var cls in ctx.GetDerivedClasses().OrderBy(c => c.Name))
            {
                var info = new InheritanceStorageAssociationInfo(cls);

#line 67 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", cls.Name, "\" EntityType=\"Model.Store.", cls.Name, "\" Schema=\"", cls.Module.SchemaName, "\" Table=\"", cls.TableName, "\"/>\r\n");
                this.WriteObjects("    <!-- inherits from ", info.ParentEntitySetName, " -->\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", info.AssociationName, "\" Association=\"Model.Store.", info.AssociationName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", info.ParentRoleName, "\" EntitySet=\"", info.ParentEntitySetName, "\" />\r\n");
                this.WriteObjects("      <End Role=\"", info.ChildRoleName, "\" EntitySet=\"", info.ChildEntitySetName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
#line 74 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 76 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets and AssociationSet for all object-object CollectionEntrys -->\r\n");
#line 79 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var rel in ctx.GetRelationsWithSeparateStorage())
            {
                string assocNameA   = rel.GetRelationAssociationName(RelationEndRole.A);
                string assocNameB   = rel.GetRelationAssociationName(RelationEndRole.B);
                string esName       = rel.GetRelationClassName();
                string esSchemaName = rel.Module.SchemaName;
                string esTableName  = rel.GetRelationTableName();


#line 88 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <!-- \r\n");
#line 90 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                RelationDebugTemplate.Call(Host, ctx, rel);

#line 92 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    -->\r\n");
                this.WriteObjects("    <EntitySet Name=\"", esName, "\" EntityType=\"Model.Store.", esName, "\" Schema=\"", esSchemaName, "\" Table=\"", esTableName, "\" />\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocNameA, "\" Association=\"Model.Store.", assocNameA, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", rel.A.RoleName, "\" EntitySet=\"", rel.A.Type.Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", esName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocNameB, "\" Association=\"Model.Store.", assocNameB, "\" >\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", esName, "\" />\r\n");
                this.WriteObjects("      <End Role=\"", rel.B.RoleName, "\" EntitySet=\"", rel.B.Type.Name, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
                this.WriteObjects("    \r\n");
#line 104 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 106 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- AssociationSets for all object-object relations which do not need CollectionEntrys -->\r\n");
#line 110 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var rel in ctx.GetRelationsWithoutSeparateStorage())
            {
                string assocName = rel.GetAssociationName();


#line 115 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <AssociationSet Name=\"", assocName, "\" Association=\"Model.Store.", assocName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", rel.A.RoleName, "\" EntitySet=\"", rel.A.Type.Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"", rel.B.RoleName, "\" EntitySet=\"", rel.B.Type.Name, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
#line 120 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 122 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets and AssociationSet for all object-value CollectionEntrys -->\r\n");
#line 125 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var prop in ctx.GetQuery <ValueTypeProperty>()
                     .Where(p => p.IsList && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
                string assocName = prop.GetAssociationName();
                string esName    = prop.GetCollectionEntryClassName();

#line 134 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", esName, "\" EntityType=\"Model.Store.", esName, "\" Schema=\"", prop.Module.SchemaName, "\" Table=\"", prop.GetCollectionEntryTable(), "\" />\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocName, "\" Association=\"Model.Store.", assocName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", prop.ObjectClass.Name, "\" EntitySet=\"", prop.ObjectClass.Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", esName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
                this.WriteObjects("    \r\n");
#line 141 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 143 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntitySets and AssociationSet for all object-struct CollectionEntrys -->\r\n");
#line 146 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var prop in ctx.GetQuery <CompoundObjectProperty>()
                     .Where(p => p.IsList) // && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
                string assocName = prop.GetAssociationName();
                string esName    = prop.GetCollectionEntryClassName();

#line 155 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <EntitySet Name=\"", esName, "\" EntityType=\"Model.Store.", esName, "\" Schema=\"", prop.Module.SchemaName, "\" Table=\"", prop.GetCollectionEntryTable(), "\" />\r\n");
                this.WriteObjects("    <AssociationSet Name=\"", assocName, "\" Association=\"Model.Store.", assocName, "\" >\r\n");
                this.WriteObjects("      <End Role=\"", prop.ObjectClass.Name, "\" EntitySet=\"", prop.ObjectClass.Name, "\" />\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" EntitySet=\"", esName, "\" />\r\n");
                this.WriteObjects("    </AssociationSet>\r\n");
                this.WriteObjects("    \r\n");
#line 162 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 164 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("  </EntityContainer>\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- EntityTypes for all classes -->\r\n");
#line 170 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var cls in ctx.GetQuery <ObjectClass>()
                     .OrderBy(cls => cls.Name))
            {
#line 173 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("	\r\n");
                this.WriteObjects("  <EntityType Name=\"", cls.Name, "\">\r\n");
                this.WriteObjects("    <Key>\r\n");
                this.WriteObjects("      <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("    </Key>\r\n");
                this.WriteObjects("    <Property Name=\"ID\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" ", (cls.BaseObjectClass == null) ? "StoreGeneratedPattern=\"Identity\" " : String.Empty, "/>\r\n");
#line 180 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                ApplyEntityTypeColumnDefs(cls);

#line 182 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
#line 184 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (cls.NeedsRightsTable())
                {
#line 187 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("    <EntityType Name=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("      <Key>\r\n");
                    this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                    this.WriteObjects("        <PropertyRef Name=\"Identity\" />\r\n");
                    this.WriteObjects("      </Key>\r\n");
                    this.WriteObjects("      <Property Name=\"ID\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" />\r\n");
                    this.WriteObjects("      <Property Name=\"Identity\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" />\r\n");
                    this.WriteObjects("      <Property Name=\"Right\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" />\r\n");
                    this.WriteObjects("    </EntityType>\r\n");
                    this.WriteObjects("    <Association Name=\"", Construct.SecurityRulesFKName(cls), "\">\r\n");
                    this.WriteObjects("      <End Role=\"", cls.Name, "\" Type=\"Model.Store.", cls.Name, "\" Multiplicity=\"1\" />\r\n");
                    this.WriteObjects("      <End Role=\"", Construct.SecurityRulesClassName(cls), "\" Type=\"Model.Store.", Construct.SecurityRulesClassName(cls), "\" Multiplicity=\"*\" />\r\n");
                    this.WriteObjects("      <ReferentialConstraint>\r\n");
                    this.WriteObjects("        <Principal Role=\"", cls.Name, "\">\r\n");
                    this.WriteObjects("          <PropertyRef Name=\"ID\" />\r\n");
                    this.WriteObjects("        </Principal>\r\n");
                    this.WriteObjects("        <Dependent Role=\"", Construct.SecurityRulesClassName(cls), "\">\r\n");
                    this.WriteObjects("          <PropertyRef Name=\"ID\" />\r\n");
                    this.WriteObjects("        </Dependent>\r\n");
                    this.WriteObjects("      </ReferentialConstraint>\r\n");
                    this.WriteObjects("    </Association>\r\n");
#line 209 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }
            }

#line 213 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- EntityTypes for all object-object CollectionEntrys with their associations -->\r\n");
#line 216 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var rel in ctx.GetRelationsWithSeparateStorage())
            {
                string ceName  = rel.GetRelationClassName();
                string fkAName = rel.GetRelationFkColumnName(RelationEndRole.A);
                string fkBName = rel.GetRelationFkColumnName(RelationEndRole.B);

#line 221 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("	\r\n");
                this.WriteObjects("  <EntityType Name=\"", ceName, "\">\r\n");
                this.WriteObjects("    <Key>\r\n");
                this.WriteObjects("      <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("    </Key>\r\n");
                this.WriteObjects("    <Property Name=\"ID\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" StoreGeneratedPattern=\"Identity\" />\r\n");
#line 228 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (rel.A.Type.ImplementsIExportable() && rel.B.Type.ImplementsIExportable())
                {
#line 231 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("	<Property Name=\"ExportGuid\" Type=\"", schemaProvider.DbTypeToNative(DbType.Guid), "\" Nullable=\"false\" />\r\n");
#line 233 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }

#line 235 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <Property Name=\"", fkAName, "\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 237 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (rel.NeedsPositionStorage(RelationEndRole.A))
                {
#line 240 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("    <Property Name=\"", fkAName, "", Zetbox.API.Helper.PositionSuffix, "\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 242 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }

#line 244 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <Property Name=\"", fkBName, "\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 246 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (rel.NeedsPositionStorage(RelationEndRole.B))
                {
#line 249 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("    <Property Name=\"", fkBName, "", Zetbox.API.Helper.PositionSuffix, "\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 251 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }

#line 253 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("  </EntityType>\r\n");
                this.WriteObjects("\r\n");
                this.WriteObjects("  <!-- A to CollectionEntry -->\r\n");
                this.WriteObjects("  <Association Name=\"", rel.GetRelationAssociationName(RelationEndRole.A), "\">\r\n");
                this.WriteObjects("    <End Role=\"", rel.A.RoleName, "\" Type=\"Model.Store.", rel.A.Type.Name, "\" Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <End Role=\"CollectionEntry\" Type=\"Model.Store.", ceName, "\" Multiplicity=\"*\" />\r\n");
                this.WriteObjects("    <ReferentialConstraint>\r\n");
                this.WriteObjects("      <Principal Role=\"", rel.A.RoleName, "\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Principal>\r\n");
                this.WriteObjects("      <Dependent Role=\"CollectionEntry\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"", fkAName, "\" />\r\n");
                this.WriteObjects("      </Dependent>\r\n");
                this.WriteObjects("    </ReferentialConstraint>\r\n");
                this.WriteObjects("  </Association>\r\n");
                this.WriteObjects("\r\n");
                this.WriteObjects("  <!-- B to CollectionEntry -->\r\n");
                this.WriteObjects("  <Association Name=\"", rel.GetRelationAssociationName(RelationEndRole.B), "\">\r\n");
                this.WriteObjects("    <End Role=\"", rel.B.RoleName, "\" Type=\"Model.Store.", rel.B.Type.Name, "\" Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <End Role=\"CollectionEntry\" Type=\"Model.Store.", ceName, "\" Multiplicity=\"*\" />\r\n");
                this.WriteObjects("    <ReferentialConstraint>\r\n");
                this.WriteObjects("      <Principal Role=\"", rel.B.RoleName, "\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Principal>\r\n");
                this.WriteObjects("      <Dependent Role=\"CollectionEntry\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"", fkBName, "\" />\r\n");
                this.WriteObjects("      </Dependent>\r\n");
                this.WriteObjects("    </ReferentialConstraint>\r\n");
                this.WriteObjects("  </Association>\r\n");
                this.WriteObjects("\r\n");
#line 284 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 286 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- Associations for all object-object relations without CollectionEntry (1:1, 1:N) -->\r\n");
#line 290 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var rel in ctx.GetRelationsWithoutSeparateStorage())
            {
                RelationEnd principal, dependent;

                switch (rel.Storage)
                {
                case StorageType.MergeIntoA:
                    principal = rel.B;
                    dependent = rel.A;
                    break;

                case StorageType.MergeIntoB:
                    principal = rel.A;
                    dependent = rel.B;
                    break;

                default:
                    throw new NotImplementedException();
                }

#line 308 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("\r\n");
                this.WriteObjects("  <Association Name=\"", rel.GetAssociationName(), "\">\r\n");
                this.WriteObjects("    <End Role=\"", principal.RoleName, "\" Type=\"Model.Store.", principal.Type.Name, "\" Multiplicity=\"", principal.Multiplicity.ToSsdlMultiplicity().ToXmlValue(), "\" />\r\n");
                this.WriteObjects("    <End Role=\"", dependent.RoleName, "\" Type=\"Model.Store.", dependent.Type.Name, "\" Multiplicity=\"*\" />\r\n");
                this.WriteObjects("    <ReferentialConstraint>\r\n");
                this.WriteObjects("      <Principal Role=\"", principal.RoleName, "\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Principal>\r\n");
                this.WriteObjects("      <Dependent Role=\"", dependent.RoleName, "\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"fk_", principal.RoleName, "\" />\r\n");
                this.WriteObjects("      </Dependent>\r\n");
                this.WriteObjects("    </ReferentialConstraint>\r\n");
                this.WriteObjects("  </Association>\r\n");
                this.WriteObjects("\r\n");
#line 323 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 325 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("  <!-- derived->base ObjectClass references -->\r\n");
#line 329 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var cls in ctx.GetDerivedClasses().OrderBy(c => c.Name))
            {
                var parentType = cls.BaseObjectClass;
                var childType  = cls;

                string parentRoleName = Construct.AssociationParentRoleName(parentType);
                string childRoleName  = Construct.AssociationChildRoleName(childType);

#line 337 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("  <Association Name=\"", Construct.InheritanceAssociationName(parentType, childType), "\">\r\n");
                this.WriteObjects("    <End Role=\"", parentRoleName, "\" Type=\"Model.Store.", parentType.Name, "\" Multiplicity=\"1\" />\r\n");
                this.WriteObjects("    <End Role=\"", childRoleName, "\" Type=\"Model.Store.", childType.Name, "\" Multiplicity=\"0..1\" />\r\n");
                this.WriteObjects("    <ReferentialConstraint>\r\n");
                this.WriteObjects("      <Principal Role=\"", parentRoleName, "\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Principal>\r\n");
                this.WriteObjects("      <Dependent Role=\"", childRoleName, "\">\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Dependent>\r\n");
                this.WriteObjects("    </ReferentialConstraint>\r\n");
                this.WriteObjects("  </Association>\r\n");
#line 349 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 351 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntityTypes and Associations for all object-value CollectionEntrys -->\r\n");
#line 355 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var prop in ctx.GetQuery <ValueTypeProperty>()
                     .Where(p => p.IsList && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
                string assocName = prop.GetAssociationName();

                // the name of the class containing this list
                string containerTypeName = prop.ObjectClass.Name;
                // the name of the CollectionEntry class
                string entryTypeName = prop.GetCollectionEntryClassName();
                // the name of the contained type
                string itemTypeName = schemaProvider.DbTypeToNative(DbTypeMapper.GetDbTypeForProperty(prop.GetType()));

                string constraint = String.Empty;
                if (prop is StringProperty)
                {
                    var sProp = (StringProperty)prop;
                    constraint += String.Format("MaxLength=\"{0}\" ", sProp.GetMaxLength());
                }
                if (prop is DecimalProperty)
                {
                    var dProp = (DecimalProperty)prop;
                    constraint += String.Format("Precision=\"{0}\" Scale=\"{1}\" ", dProp.Precision, dProp.Scale);
                }


#line 381 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <EntityType Name=\"", entryTypeName, "\" >\r\n");
                this.WriteObjects("      <Key>\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Key>\r\n");
                this.WriteObjects("      <Property Name=\"ID\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" StoreGeneratedPattern=\"Identity\" />\r\n");
                this.WriteObjects("      <Property Name=\"fk_", containerTypeName, "\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
                this.WriteObjects("      <Property Name=\"", prop.Name, "\" Type=\"", itemTypeName, "\" ", constraint, "/>\r\n");
#line 389 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (prop.HasPersistentOrder)
                {
#line 392 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("    <Property Name=\"", prop.Name, "Index\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 394 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }

#line 396 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    </EntityType>\r\n");
                this.WriteObjects("\r\n");
                this.WriteObjects("    <Association Name=\"", prop.GetAssociationName(), "\">\r\n");
                this.WriteObjects("      <End Role=\"", containerTypeName, "\" Type=\"Model.Store.", containerTypeName, "\" Multiplicity=\"0..1\">\r\n");
                this.WriteObjects("        <OnDelete Action=\"Cascade\" />\r\n");
                this.WriteObjects("      </End>\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" Type=\"Model.Store.", entryTypeName, "\" Multiplicity=\"*\" />\r\n");
                this.WriteObjects("      <ReferentialConstraint>\r\n");
                this.WriteObjects("        <Principal Role=\"", containerTypeName, "\">\r\n");
                this.WriteObjects("          <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("        </Principal>\r\n");
                this.WriteObjects("        <Dependent Role=\"CollectionEntry\">\r\n");
                this.WriteObjects("          <PropertyRef Name=\"fk_", containerTypeName, "\" />\r\n");
                this.WriteObjects("        </Dependent>\r\n");
                this.WriteObjects("      </ReferentialConstraint>\r\n");
                this.WriteObjects("    </Association>\r\n");
                this.WriteObjects("\r\n");
#line 414 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 416 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("\r\n");
            this.WriteObjects("    <!-- EntityTypes and Associations for all object-struct CollectionEntrys -->\r\n");
#line 419 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            foreach (var prop in ctx.GetQuery <CompoundObjectProperty>()
                     .Where(p => p.IsList) // && !p.IsCalculated)
                     .Where(p => p.ObjectClass is ObjectClass)
                     .OrderBy(p => p.ObjectClass.Name)
                     .ThenBy(p => p.Name))
            {
                string assocName = prop.GetAssociationName();

                // the name of the class containing this list
                string containerTypeName = prop.ObjectClass.Name;
                // the name of the CollectionEntry class
                string entryTypeName = prop.GetCollectionEntryClassName();

#line 432 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    <EntityType Name=\"", entryTypeName, "\" >\r\n");
                this.WriteObjects("      <Key>\r\n");
                this.WriteObjects("        <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("      </Key>\r\n");
                this.WriteObjects("      <Property Name=\"ID\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"false\" StoreGeneratedPattern=\"Identity\" />\r\n");
                this.WriteObjects("      <Property Name=\"fk_", containerTypeName, "\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 439 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                ApplyEntityTypeColumnDefs(prop);

#line 442 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                if (prop.HasPersistentOrder)
                {
#line 445 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                    this.WriteObjects("    <Property Name=\"", prop.Name, "Index\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Nullable=\"true\" />\r\n");
#line 447 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                }

#line 449 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
                this.WriteObjects("    </EntityType>\r\n");
                this.WriteObjects("\r\n");
                this.WriteObjects("    <Association Name=\"", prop.GetAssociationName(), "\">\r\n");
                this.WriteObjects("      <End Role=\"", containerTypeName, "\" Type=\"Model.Store.", containerTypeName, "\" Multiplicity=\"0..1\">\r\n");
                this.WriteObjects("        <OnDelete Action=\"Cascade\" />\r\n");
                this.WriteObjects("      </End>\r\n");
                this.WriteObjects("      <End Role=\"CollectionEntry\" Type=\"Model.Store.", entryTypeName, "\" Multiplicity=\"*\" />\r\n");
                this.WriteObjects("      <ReferentialConstraint>\r\n");
                this.WriteObjects("        <Principal Role=\"", containerTypeName, "\">\r\n");
                this.WriteObjects("          <PropertyRef Name=\"ID\" />\r\n");
                this.WriteObjects("        </Principal>\r\n");
                this.WriteObjects("        <Dependent Role=\"CollectionEntry\">\r\n");
                this.WriteObjects("          <PropertyRef Name=\"fk_", containerTypeName, "\" />\r\n");
                this.WriteObjects("        </Dependent>\r\n");
                this.WriteObjects("      </ReferentialConstraint>\r\n");
                this.WriteObjects("    </Association>\r\n");
                this.WriteObjects("\r\n");
#line 467 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            }

#line 469 "P:\zetbox\Zetbox.DalProvider.EF.Generator\Templates\EfModel\Model.ssdl.cst"
            this.WriteObjects("	<Function Name=\"GetContinuousSequenceNumber\" Aggregate=\"false\" BuiltIn=\"false\" NiladicFunction=\"false\" IsComposable=\"false\" ParameterTypeSemantics=\"AllowImplicitConversion\" Schema=\"dbo\">\r\n");
            this.WriteObjects("          <Parameter Name=\"seqNumber\" Type=\"", schemaProvider.DbTypeToNative(DbType.Guid), "\" Mode=\"In\" />\r\n");
            this.WriteObjects("		  <Parameter Name=\"result\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Mode=\"Out\" />\r\n");
            this.WriteObjects("    </Function>\r\n");
            this.WriteObjects("    <Function Name=\"GetSequenceNumber\" Aggregate=\"false\" BuiltIn=\"false\" NiladicFunction=\"false\" IsComposable=\"false\" ParameterTypeSemantics=\"AllowImplicitConversion\" Schema=\"dbo\">\r\n");
            this.WriteObjects("        <Parameter Name=\"seqNumber\" Type=\"", schemaProvider.DbTypeToNative(DbType.Guid), "\" Mode=\"In\" />\r\n");
            this.WriteObjects("		<Parameter Name=\"result\" Type=\"", schemaProvider.DbTypeToNative(DbType.Int32), "\" Mode=\"Out\" />\r\n");
            this.WriteObjects("    </Function>\r\n");
            this.WriteObjects("</Schema>");
        }