public EntityTableMapping(EntityType entityType) { if (entityType == null) throw new ArgumentNullException(); EntityType = entityType; InitializeComponent(); tableNullValues.Collection = NullValue.GetValues("<Delete>"); }
public void BindEntityType(EntityType entityType) { EntityType = entityType; Association = null; if (entityType == null) { Visibility = Visibility.Collapsed; return; } nameTextBlock.Text = entityType.Name; Clear(); Visibility = Visibility.Visible; foreach (var tableMapped in entityType.Mapping.MappedSSDLTables.ToList()) { var tableMapping = AddNewEntityTableMapping(); tableMapping.Tables = PossiblesTables.Union(new[] { tableMapped }); tableMapping.TableComboBoxValue.ComboSelectedValue = tableMapped; } }
public EntityType AddEntityType(string typeName, string entitySetName, EntityType baseType) { var value = new EntityType { Name = typeName, EntitySetName = entitySetName, Container = this, BaseType = baseType }; EntityTypes.Add(value); return value; }
public Association.Association AddAssociation(string associationName, string navigationProperty1Name, EntityType navigationProperty1EnityType, Cardinality navigationProperty1Cardinality, string navigationProperty2Name, EntityType navigationProperty2EnityType, Cardinality navigationProperty2Cardinality) { var association = new Association.Association { Container = this, Name = associationName }; var navigationProperty1 = new NavigationProperty(association) { Name = navigationProperty1Name, Cardinality = navigationProperty1Cardinality }; navigationProperty1EnityType.NavigationProperties.Add(navigationProperty1); association.PropertyEnd1 = navigationProperty1; var navigationProperty2 = new NavigationProperty(association) { Name = navigationProperty2Name, Cardinality = navigationProperty2Cardinality }; navigationProperty2EnityType.NavigationProperties.Add(navigationProperty2); association.PropertyEnd2 = navigationProperty2; return association; }
protected virtual void OnSubEntityTypeAdded(EntityType entityType) { if (SubEntityTypeAdded != null) SubEntityTypeAdded(this, entityType); }
public bool IsBaseType(EntityType type) { var t = type; while ((t = t.BaseType) != null) if (t == this) return true; return false; }
private static XElement CUDFunctionMapping(EntityType entityType, string entityContainerNamespace, string storeContainerNamespace) { EntityTypeMapping mapping = entityType.Mapping; if (mapping.InsertFunctionMapping == null || mapping.UpdateFunctionMapping == null || mapping.DeleteFunctionMapping == null) return null; XElement modificationFunctionMapping = new XElement(mslNamespace + "ModificationFunctionMapping"); var insertFunction = mapping.InsertFunctionMapping; if (insertFunction != null) { XElement insertFunctionElement = new XElement(mslNamespace + "InsertFunction", new XAttribute("FunctionName", string.Concat(storeContainerNamespace, insertFunction.SSDLFunction.Name))); insertFunctionElement.Add(CUDFunctionMappingAssociation(insertFunction)); insertFunctionElement.Add(CUDFunctionMappingParameters(insertFunction)); insertFunctionElement.Add(CUDFunctionMappingResults(insertFunction)); modificationFunctionMapping.AddElement(insertFunctionElement); } var updateFunction = mapping.UpdateFunctionMapping; if (updateFunction != null) { XElement updateFunctionElement = new XElement(mslNamespace + "UpdateFunction", new XAttribute("FunctionName", string.Concat(storeContainerNamespace, updateFunction.SSDLFunction.Name))); updateFunctionElement.Add(CUDFunctionMappingAssociation(updateFunction)); updateFunctionElement.Add(CUDFunctionMappingParameters(updateFunction)); updateFunctionElement.Add(CUDFunctionMappingResults(updateFunction)); modificationFunctionMapping.AddElement(updateFunctionElement); } var deleteFunction = mapping.DeleteFunctionMapping; if (deleteFunction != null) { XElement deleteFunctionElement = new XElement(mslNamespace + "DeleteFunction", new XAttribute("FunctionName", string.Concat(storeContainerNamespace, deleteFunction.SSDLFunction.Name))); deleteFunctionElement.Add(CUDFunctionMappingAssociation(deleteFunction)); deleteFunctionElement.Add(CUDFunctionMappingParameters(deleteFunction)); deleteFunctionElement.Add(CUDFunctionMappingResults(deleteFunction)); modificationFunctionMapping.AddElement(deleteFunctionElement); } return new XElement(mslNamespace + "EntityTypeMapping", new XAttribute("TypeName", string.Concat(entityContainerNamespace, entityType.Name)), modificationFunctionMapping); }
private static CUDFunctionMapping SetCUDFunctionMapping(SSDLContainer ssdlContainer, EntityType entityType, XElement functionMappingElement) { var cudFunctionMapping = new CUDFunctionMapping(); var ssdlFunction = ssdlContainer.Functions.GetByName(GetName(functionMappingElement.Attribute("FunctionName").Value)); cudFunctionMapping.SSDLFunction = ssdlFunction; SetCUDFunctionParametersMapping(entityType, functionMappingElement, cudFunctionMapping.ParametersMapping, ssdlFunction); foreach (var scalarPropertyElement in functionMappingElement.Elements(XName.Get("ResultBinding", mslNamespace.NamespaceName))) cudFunctionMapping.ResultsMapping[entityType.AllScalarProperties.GetByName(scalarPropertyElement.Attribute("Name").Value)] = scalarPropertyElement.Attribute("ColumnName").Value; foreach (var associationEndElement in functionMappingElement.Elements(XName.Get("AssociationEnd", mslNamespace.NamespaceName))) { var navigationProperty = entityType.NavigationProperties.First(np => np.Association.AssociationSetName == associationEndElement.Attribute("AssociationSet").Value); var cudFunctionAssociationMapping = new CUDFunctionAssociationMapping { Association = navigationProperty.Association, FromRole = associationEndElement.Attribute("From").Value, ToRole = associationEndElement.Attribute("To").Value }; cudFunctionMapping.AssociationMappings.Add(cudFunctionAssociationMapping); SetCUDFunctionParametersScalarMapping(navigationProperty.RelatedEntityType, associationEndElement, cudFunctionAssociationMapping.AssociationPropertiesMapping, ssdlFunction); } return cudFunctionMapping; }
public PropertiesMapping(EntityType entityType, ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType.EntityType table) { EntityType = entityType; Table = table; }
private static EntityType ReadCSDLEntityType(XElement schemaElement, XElement entityContainerElement, XElement entityTypeElement, CSDLContainer container, string typeName, EntityType baseType) { var entityType = new EntityType { Name = typeName, BaseType = baseType }; SetBoolValueFromAttribute(entityTypeElement, "Abstract", isAbstract => entityType.Abstract = isAbstract); var entitySetElement = entityContainerElement.Elements(XName.Get("EntitySet", csdlNamespace.NamespaceName)).Where(ese => GetName(ese.Attribute("EntityType").Value) == entityType.Name).FirstOrDefault(); if (entitySetElement != null) { entityType.EntitySetName = entitySetElement.Attribute("Name").Value; SetVisibilityValueFromAttribute(entitySetElement, "GetterAccess", getterAccess => entityType.EntitySetVisibility = getterAccess); } ReadCSDLType(schemaElement, entityTypeElement, container, (TypeBase)entityType); return entityType; }
public EntityPropertiesMapping(EntityType entityType, ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType.EntityType table) : base(entityType, table) { }