private XElement createMiddleEntityXml(string auditMiddleTableName, string auditMiddleEntityName, string where) { var schema = _mainGenerator.GetSchema(_propertyAuditingData.JoinTable.Schema, _propertyValue.CollectionTable); var catalog = _mainGenerator.GetCatalog(_propertyAuditingData.JoinTable.Catalog, _propertyValue.CollectionTable); var middleEntityXml = MetadataTools.CreateEntity(_xmlMappingData.NewAdditionalMapping(), new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema, catalog), null, false); var middleEntityXmlId = new XElement(MetadataTools.CreateElementName("composite-id"), new XAttribute("name", _mainGenerator.VerEntCfg.OriginalIdPropName)); middleEntityXml.Add(middleEntityXmlId); // If there is a where clause on the relation, adding it to the middle entity. if (where != null) { middleEntityXml.Add(new XAttribute("where", where)); } // Adding the revision number as a foreign key to the revision info entity to the composite id of the // middle table. _mainGenerator.AddRevisionInfoRelation(middleEntityXmlId); // Adding the revision type property to the entity xml. _mainGenerator.AddRevisionType(isEmbeddableElementType() ? middleEntityXmlId : middleEntityXml, middleEntityXml); // All other properties should also be part of the primary key of the middle entity. return(middleEntityXmlId); }
private XmlElement CreateMiddleEntityXml(String auditMiddleTableName, String auditMiddleEntityName, String where) { String schema = mainGenerator.GetSchema(propertyAuditingData.JoinTable.Schema, propertyValue.CollectionTable); String catalog = mainGenerator.GetCatalog(propertyAuditingData.JoinTable.Catalog, propertyValue.CollectionTable); XmlElement middleEntityXml = MetadataTools.CreateEntity(xmlMappingData.newAdditionalMapping(), new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema, catalog), null); XmlElement middleEntityXmlId = middleEntityXml.OwnerDocument.CreateElement("composite-id"); middleEntityXml.AppendChild(middleEntityXmlId); // If there is a where clause on the relation, adding it to the middle entity. if (where != null) { middleEntityXml.SetAttribute("where", where); } middleEntityXmlId.SetAttribute("name", mainGenerator.VerEntCfg.OriginalIdPropName); // Adding the revision number as a foreign key to the revision info entity to the composite id of the // middle table. mainGenerator.AddRevisionInfoRelation(middleEntityXmlId); // Adding the revision type property to the entity xml. mainGenerator.AddRevisionType(middleEntityXml); // All other properties should also be part of the primary key of the middle entity. return(middleEntityXmlId); }