protected void RemoveData(Data.DataXml.Entities DataXML, Data.SchemaXml.Entities SchemaXML) { foreach (var entity in DataXML.Entity) { String logicalName = entity.Name; var schemaData = SchemaXML.Entity.Where(x => x.Name.Equals(logicalName)).First(); this.VerifyEntityExists(schemaData); this.AddMetadataFromSchema(schemaData); foreach (var record in entity.Records.Record) { Entity holdingEntity = new Entity(logicalName, Guid.Parse(record.Id)); foreach (var field in record.Field) { holdingEntity[field.Name] = Builders.XmlImporter.GetObjectFromFieldNodeType(field, schemaData); } this.RemoveData(holdingEntity); } foreach (var relationship in entity.M2mrelationships.M2mrelationship) { Dictionary <Guid, List <Guid> > relationshipPairs = CompileRelationshipData(relationship); this._Entities[logicalName].RemoveRelationshipsWhereIdentical(relationship.M2mrelationshipname, relationshipPairs); } } }
protected void AppendData(Data.DataXml.Entities DataXML, Data.SchemaXml.Entities SchemaXML) { foreach (var schemaData in SchemaXML.Entity) { this.VerifyEntityExists(schemaData); this.AddMetadataFromSchema(schemaData); } foreach (var entity in DataXML.Entity) { String logicalName = entity.Name; var schemaData = SchemaXML.Entity.Where(x => x.Name.Equals(logicalName)).First(); this.VerifyEntityExists(schemaData); this.AddMetadataFromSchema(schemaData); foreach (var record in entity.Records.Record) { Entity holdingEntity = new Entity(logicalName, Guid.Parse(record.Id)); foreach (var field in record.Field) { holdingEntity[field.Name] = Builders.XmlImporter.GetObjectFromFieldNodeType(field, schemaData); } this.AppendData(holdingEntity); } if (this._Entities[logicalName].Identifiers.Count == 0) { List <String> setIdentifiers = schemaData.Fields.Field.Where(field => field.UpdateCompare == "true").Select(field => field.Name).ToList(); if (setIdentifiers.Count == 0) { setIdentifiers.Add(schemaData.Primaryidfield); } this._Entities[logicalName].Identifiers = setIdentifiers; } if (this._Entities[logicalName].PluginsDisabled == null && !String.IsNullOrEmpty(schemaData.Disableplugins)) { this._Entities[logicalName].PluginsDisabled = Boolean.Parse(schemaData.Disableplugins); } foreach (var relationship in entity.M2mrelationships.M2mrelationship) { Dictionary <Guid, List <Guid> > relationshipPairs = CompileRelationshipData(relationship); this._Entities[entity.Name].AppendM2MDataToEntity(relationship.M2mrelationshipname, relationshipPairs); } } }