public ComplexPropertiesMapping(TypeBase type, MappingBase mapping, ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType.EntityType table) { Type = type; Mapping = mapping; Table = table; TPC = true; }
internal override bool TryGetTypeByName( string fullName, bool ignoreCase, out TypeUsage typeUsage) { typeUsage = (TypeUsage)null; MappingBase map = (MappingBase)null; if (this.MetadataWorkspace.TryGetMap(fullName, DataSpace.OSpace, ignoreCase, DataSpace.OCSpace, out map)) { if (map.EdmItem.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType) { PrimitiveType mappedPrimitiveType = this.MetadataWorkspace.GetMappedPrimitiveType(((PrimitiveType)map.EdmItem).PrimitiveTypeKind, DataSpace.CSpace); if (mappedPrimitiveType != null) { typeUsage = EdmProviderManifest.Instance.GetCanonicalModelTypeUsage(mappedPrimitiveType.PrimitiveTypeKind); } } else { typeUsage = ClrPerspective.GetMappedTypeUsage(map); } } return(null != typeUsage); }
// <summary> // Look up a type in the target data space based upon the fullName // </summary> // <param name="fullName"> fullName </param> // <param name="ignoreCase"> true for case-insensitive lookup </param> // <param name="typeUsage"> The type usage object to return </param> // <returns> True if the retrieval succeeded </returns> internal override bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage) { typeUsage = null; MappingBase map = null; // From ClrPerspective, we should not allow anything from SSpace. So make sure that the CSpace type does not // have the Target attribute if (MetadataWorkspace.TryGetMap(fullName, DataSpace.OSpace, ignoreCase, DataSpace.OCSpace, out map)) { // Check if it's primitive type, if so, then use the MetadataWorkspace to get the mapped primitive type if (map.EdmItem.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType) { // Reassign the variable with the provider primitive type, then create the type usage var primitiveType = MetadataWorkspace.GetMappedPrimitiveType( ((PrimitiveType)map.EdmItem).PrimitiveTypeKind, DataSpace.CSpace); if (primitiveType != null) { typeUsage = EdmProviderManifest.Instance.GetCanonicalModelTypeUsage(primitiveType.PrimitiveTypeKind); } } else { Debug.Assert(((GlobalItem)map.EdmItem).DataSpace == DataSpace.CSpace); typeUsage = GetMappedTypeUsage(map); } } return(null != typeUsage); }
public override void Initialize(MappingBase parent) { base.Initialize(parent); int colNo = 0; this.MultiFieldMapper.Initialize(this, ref colNo); }
public override void Initialize(MappingBase parent) { if (null == this.FieldType) { throw new Exception(FieldInfo + " - FieldType is null."); } base.Initialize(parent); }
public override void Initialize(MappingBase parent, ref int startingPosNo) { this.Parent = parent; foreach (FixedLengthFieldMapper <V> f in this.FieldMappers) { f.Initialize(this, ref startingPosNo); } }
public virtual void Initialize(MappingBase parent, ref int colNo) { if (this.ColumnNo == 0) { this.ColumnNo = colNo++; } else { colNo = this.ColumnNo; } }
protected void SetParent(MappingBase currentMapping) { if (currentMapping.ParentIDSource == Enumerations.ParentSource.Global) { this._parent = this.GetItem(currentMapping.GlobalParentID); if (this._parent == null) { LogStatus("A valid Item ID must be specified for GlobalParentID when ParentSource is Global."); return; } } }
public override void Initialize(MappingBase parent, ref int startPos) { base.Initialize(parent); if (null != this.SignatureFieldMapper) { this.SignatureFieldMapper.Initialize(this, ref startPos); } foreach (var f in this.FieldMappers) { f.Initialize(this, ref startPos); } }
private static TypeUsage GetMappedTypeUsage(MappingBase map) { TypeUsage typeUsage = (TypeUsage)null; if (map != null) { MetadataItem edmItem = map.EdmItem; EdmType edmType = edmItem as EdmType; if (edmItem != null && edmType != null) { typeUsage = TypeUsage.Create(edmType); } } return(typeUsage); }
public override void Initialize(MappingBase parent) { base.Initialize(parent); if (null != this.HeaderMapper) { int startPosNo = 0; this.HeaderMapper.Initialize(this, ref startPosNo); } if (null != this.FooterMapper) { int startPosNo = 0; this.FooterMapper.Initialize(this, ref startPosNo); } this.DetailMapper.Initialize(this); }
// <summary> // Given a map, dereference the EdmItem, ensure that it is // an EdmType and return a TypeUsage for the type, otherwise // return null. // </summary> // <param name="map"> The OC map to use to get the EdmType </param> // <returns> A TypeUsage for the mapped EdmType or null if no EdmType was mapped </returns> private static TypeUsage GetMappedTypeUsage(MappingBase map) { TypeUsage typeUsage = null; if (null != map) { var item = map.EdmItem; var edmItem = item as EdmType; if (null != item && edmItem != null) { typeUsage = TypeUsage.Create(edmItem); } } return(typeUsage); }
public override void Initialize(MappingBase parent) { base.Initialize(parent); if (null != this.SignatureRecordMapper) { this.SignatureRecordMapper.Initialize(this); } if (null != this.RecordMappers) { foreach (var r in this.RecordMappers) { r.Initialize(this); } } }
public virtual void Initialize(MappingBase parent, ref int colNo) { base.Initialize(parent); if (this.ColumnNo == 0) { this.ColumnNo = colNo; } else if (colNo <= this.ColumnNo) { colNo = this.ColumnNo; } else { throw new Exception("Error in " + this.FieldInfo + ": Column no. is out of sequence."); } ++colNo; }
// <summary> // Given the type in the target space and the member name in the source space, // get the corresponding member in the target space // For e.g. consider a Conceptual Type Abc with a member def and a CLR type // XAbc with a member YDef. If one has a reference to Abc one can // invoke GetMember(Abc,"YDef") to retrieve the member metadata for def // </summary> // <param name="type"> The type in the target perspective </param> // <param name="memberName"> the name of the member in the source perspective </param> // <param name="ignoreCase"> true for case-insensitive lookup </param> // <param name="outMember"> returns the edmMember if a match is found </param> // <returns> true if a match is found, otherwise false </returns> internal override bool TryGetMember(StructuralType type, String memberName, bool ignoreCase, out EdmMember outMember) { outMember = null; MappingBase map = null; if (MetadataWorkspace.TryGetMap(type, DataSpace.OCSpace, out map)) { var objectTypeMap = map as ObjectTypeMapping; if (objectTypeMap != null) { var objPropertyMapping = objectTypeMap.GetMemberMapForClrMember(memberName, ignoreCase); if (null != objPropertyMapping) { outMember = objPropertyMapping.EdmMember; return(true); } } } return(false); }
internal override bool TryGetMember( StructuralType type, string memberName, bool ignoreCase, out EdmMember outMember) { outMember = (EdmMember)null; MappingBase map = (MappingBase)null; if (this.MetadataWorkspace.TryGetMap((GlobalItem)type, DataSpace.OCSpace, out map)) { ObjectTypeMapping objectTypeMapping = map as ObjectTypeMapping; if (objectTypeMapping != null) { ObjectMemberMapping memberMapForClrMember = objectTypeMapping.GetMemberMapForClrMember(memberName, ignoreCase); if (memberMapForClrMember != null) { outMember = memberMapForClrMember.EdmMember; return(true); } } } return(false); }
private bool RemoveSSDLTableToComplexProperty(ComplexProperty complexProperty, MappingBase mapping, SSDL.EntityType.EntityType ssdlTable) { bool deleteAll = true; foreach (var prop in mapping.Mapping.Keys.ToList()) { var propMapping = mapping.Mapping[prop]; if (propMapping.Count == 1) mapping.RemoveMapping(prop); else { propMapping.Remove(ssdlTable); deleteAll = false; } } foreach (var complexProp in mapping.ComplexMapping.Keys.ToList()) if (RemoveSSDLTableToComplexProperty(complexProp, mapping.ComplexMapping[complexProp], ssdlTable)) mapping.ComplexMapping.Remove(complexProp); else deleteAll = false; return deleteAll; }
public virtual void Initialize(MappingBase parent, ref int startingPosNo) { this.Parent = parent; this.ColumnNo = startingPosNo; startingPosNo += this.Length; }
private static IEnumerable<XElement> MappingComplexProperties(TypeBase type, MappingBase mapping, EDMObjects.SSDL.EntityType.EntityType table, string entityContainerNamespace) { foreach (ComplexProperty complexProperty in type.AllComplexProperties) { ComplexPropertyMapping complexPropertyMapping = mapping.GetEntityTypeSpecificComplexPropertyMapping(complexProperty); if (complexPropertyMapping != null) { XElement complexPropertyElement = new XElement(mslNamespace + "ComplexProperty", new XAttribute("Name", complexProperty.Name)); IEnumerable<PropertyMapping> scalarMappings = complexPropertyMapping.GetSpecificMappingForTable(table); foreach (PropertyMapping scalarMapping in scalarMappings) { complexPropertyElement.AddElement(new XElement(mslNamespace + "ScalarProperty", new XAttribute("Name", scalarMapping.Property.Name), new XAttribute("ColumnName", scalarMapping.Column.Name))); } foreach (ComplexProperty subComplexProperty in complexProperty.ComplexType.ComplexProperties) { complexPropertyElement.Add(MappingComplexProperties(complexProperty.ComplexType, complexPropertyMapping, table, entityContainerNamespace)); } yield return complexPropertyElement; } } }
private static void MapComplexProperties(XElement complexMappingParentElement, MappingBase complexMappingOwner, TypeBase type, ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType.EntityType table) { foreach (var complexPropertyElement in complexMappingParentElement.Elements(XName.Get("ComplexProperty", mslNamespace.NamespaceName))) { var complexProperty = type.AllComplexProperties.GetByName(complexPropertyElement.Attribute("Name").Value); var complexPropertyMapping = complexMappingOwner[complexProperty]; foreach (var scalarPropertyElement in complexPropertyElement.Elements(XName.Get("ScalarProperty", mslNamespace.NamespaceName))) { var scalarProperty = complexProperty.ComplexType.AllScalarProperties.GetByName(scalarPropertyElement.Attribute("Name").Value); var column = table.Properties.First(c => c.Name == scalarPropertyElement.Attribute("ColumnName").Value); complexPropertyMapping[scalarProperty, table] = column; } MapComplexProperties(complexPropertyElement, complexPropertyMapping, complexProperty.ComplexType, table); } }
public override void Initialize(MappingBase parent, ref int startingPosNo) { this.SignatureMapper.Initialize(this, ref startingPosNo); base.Initialize(parent, ref startingPosNo); }
public ComplexPropertyMapping(ComplexProperty complexProperty, MappingBase mapping, ICSharpCode.Data.EDMDesigner.Core.EDMObjects.SSDL.EntityType.EntityType table) { ComplexProperty = complexProperty; Mapping = mapping; Table = table; }
private static IEnumerable <XElement> MappingComplexProperties(TypeBase type, MappingBase mapping, EDMObjects.SSDL.EntityType.EntityType table, string entityContainerNamespace) { foreach (ComplexProperty complexProperty in type.AllComplexProperties) { ComplexPropertyMapping complexPropertyMapping = mapping.GetEntityTypeSpecificComplexPropertyMapping(complexProperty); if (complexPropertyMapping != null) { XElement complexPropertyElement = new XElement(mslNamespace + "ComplexProperty", new XAttribute("Name", complexProperty.Name)); IEnumerable <PropertyMapping> scalarMappings = complexPropertyMapping.GetSpecificMappingForTable(table); foreach (PropertyMapping scalarMapping in scalarMappings) { complexPropertyElement.AddElement(new XElement(mslNamespace + "ScalarProperty", new XAttribute("Name", scalarMapping.Property.Name), new XAttribute("ColumnName", scalarMapping.Column.Name))); } foreach (ComplexProperty subComplexProperty in complexProperty.ComplexType.ComplexProperties) { complexPropertyElement.Add(MappingComplexProperties(complexProperty.ComplexType, complexPropertyMapping, table, entityContainerNamespace)); } yield return(complexPropertyElement); } } }
private void AddMapping(MappingBase mapping) { mapping.Mapper = this; mapping.Scope = _state.CurrentScope; _state.Mappings.Add(mapping); }