private void WriteEntityTypeMappingElement(EntityTypeMapping entityTypeMapping)
 {
     this._xmlWriter.WriteStartElement("EntityTypeMapping");
     this._xmlWriter.WriteAttributeString("TypeName", MslXmlSchemaWriter.GetEntityTypeName(this._entityTypeNamespace + "." + entityTypeMapping.EntityType.Name, entityTypeMapping.IsHierarchyMapping));
     foreach (MappingFragment mappingFragment in entityTypeMapping.MappingFragments)
     {
         this.WriteMappingFragmentElement(mappingFragment);
     }
     this._xmlWriter.WriteEndElement();
 }
Esempio n. 2
0
        // <summary>
        // Serialize the <see cref="DbModel" /> to the XmlWriter
        // </summary>
        // <param name="databaseMapping"> The DbModel to serialize </param>
        // <param name="xmlWriter"> The XmlWriter to serialize to </param>
        public virtual bool Serialize(DbDatabaseMapping databaseMapping, XmlWriter xmlWriter)
        {
            Check.NotNull(databaseMapping, "databaseMapping");
            Check.NotNull(xmlWriter, "xmlWriter");

            var schemaWriter = new MslXmlSchemaWriter(xmlWriter, databaseMapping.Model.SchemaVersion);

            schemaWriter.WriteSchema(databaseMapping);

            return(true);
        }
Esempio n. 3
0
        // <summary>
        // Serialize the <see cref="DbModel" /> to the XmlWriter
        // </summary>
        // <param name="databaseMapping"> The DbModel to serialize </param>
        // <param name="xmlWriter"> The XmlWriter to serialize to </param>
        public virtual bool Serialize(DbDatabaseMapping databaseMapping, XmlWriter xmlWriter)
        {
            Check.NotNull(databaseMapping, "databaseMapping");
            Check.NotNull(xmlWriter, "xmlWriter");

            var schemaWriter = new MslXmlSchemaWriter(xmlWriter, databaseMapping.Model.SchemaVersion);

            schemaWriter.WriteSchema(databaseMapping);

            return true;
        }
 private void WriteFunctionImportEntityTypeMappingElement(
     FunctionImportEntityTypeMapping entityTypeMapping)
 {
     this._xmlWriter.WriteStartElement("EntityTypeMapping");
     this._xmlWriter.WriteAttributeString("TypeName", MslXmlSchemaWriter.CreateFunctionImportEntityTypeMappingTypeName(entityTypeMapping));
     this.WriteFunctionImportPropertyMappingElements(entityTypeMapping.PropertyMappings.Cast <FunctionImportReturnTypeScalarPropertyMapping>());
     foreach (FunctionImportEntityTypeMappingCondition condition in entityTypeMapping.Conditions)
     {
         this.WriteFunctionImportConditionElement(condition);
     }
     this._xmlWriter.WriteEndElement();
 }
Esempio n. 5
0
            public Fixture()
            {
                _stringBuilder = new StringBuilder();

                _xmlWriter = XmlWriter.Create(
                    _stringBuilder,
                    new XmlWriterSettings
                {
                    OmitXmlDeclaration = true,
                    Indent             = true
                });

                Writer = new MslXmlSchemaWriter(_xmlWriter, 3.0);
            }
 public void WriteEntitySetMappingElement(EntitySetMapping entitySetMapping)
 {
     this._xmlWriter.WriteStartElement("EntitySetMapping");
     this._xmlWriter.WriteAttributeString("Name", entitySetMapping.EntitySet.Name);
     foreach (EntityTypeMapping entityTypeMapping in entitySetMapping.EntityTypeMappings)
     {
         this.WriteEntityTypeMappingElement(entityTypeMapping);
     }
     foreach (EntityTypeModificationFunctionMapping modificationFunctionMapping in entitySetMapping.ModificationFunctionMappings)
     {
         this._xmlWriter.WriteStartElement("EntityTypeMapping");
         this._xmlWriter.WriteAttributeString("TypeName", MslXmlSchemaWriter.GetEntityTypeName(this._entityTypeNamespace + "." + modificationFunctionMapping.EntityType.Name, false));
         this.WriteModificationFunctionMapping(modificationFunctionMapping);
         this._xmlWriter.WriteEndElement();
     }
     this._xmlWriter.WriteEndElement();
 }
Esempio n. 7
0
        public void CreateFunctionImportEntityTypeMappingTypeName_returns_correct_TypeName_attribute_value()
        {
            var ofEntityTypes = new[]
            {
                new EntityType("OfType1", "Ns", DataSpace.CSpace),
                new EntityType("OfType2", "Ns", DataSpace.CSpace)
            };

            var entityTypes = new[]
            {
                new EntityType("ET1", "Ns", DataSpace.CSpace),
                new EntityType("ET2", "Ns", DataSpace.CSpace)
            };

            var mapping = new FunctionImportEntityTypeMapping(
                ofEntityTypes,
                entityTypes,
                new Collection <FunctionImportReturnTypePropertyMapping>(),
                new List <FunctionImportEntityTypeMappingCondition>());

            Assert.Equal(
                "Ns.ET1;Ns.ET2;IsTypeOf(Ns.OfType1);IsTypeOf(Ns.OfType2)",
                MslXmlSchemaWriter.CreateFunctionImportEntityTypeMappingTypeName(mapping));
        }
            public Fixture()
            {
                _stringBuilder = new StringBuilder();

                _xmlWriter = XmlWriter.Create(
                    _stringBuilder,
                    new XmlWriterSettings
                        {
                            OmitXmlDeclaration = true,
                            Indent = true
                        });

                Writer = new MslXmlSchemaWriter(_xmlWriter, 3.0);
            }
 internal static string CreateFunctionImportEntityTypeMappingTypeName(
     FunctionImportEntityTypeMapping entityTypeMapping)
 {
     return(string.Join(";", entityTypeMapping.EntityTypes.Select <EntityType, string>((Func <EntityType, string>)(e => MslXmlSchemaWriter.GetEntityTypeName(e.FullName, false))).Concat <string>(entityTypeMapping.IsOfTypeEntityTypes.Select <EntityType, string>((Func <EntityType, string>)(e => MslXmlSchemaWriter.GetEntityTypeName(e.FullName, true))))));
 }