diff --git a/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/MSLIO.cs b/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/MSLIO.cs index eacb020c92..7704bb2d9d 100644 --- a/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/MSLIO.cs +++ b/src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/IO/MSLIO.cs @@ -25,10 +25,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO { public class MSLIO : IO { - #region Methods - - #region Read - public static XDocument GenerateTypeMapping(XDocument mslDocument) { XElement mappingElement = mslDocument.Element(XName.Get("Mapping", mslNamespace.NamespaceName)); @@ -41,8 +37,10 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO if (entityContainerMappingElement == null || entityContainerMappingElement.IsEmpty) return null; - foreach (XElement entitySetMapping in entityContainerMappingElement.Elements(mslNamespace + "EntitySetMapping")) - { + foreach (XElement entitySetMapping in entityContainerMappingElement.Elements(mslNamespace + "EntitySetMapping")) { + if (entitySetMapping.HasEntityTypeMappingChildElement()) + continue; + string name = entitySetMapping.Attribute("Name").Value; string storeEntitySet = entitySetMapping.Attribute("StoreEntitySet").Value; string typeName = entitySetMapping.Attribute("TypeName").Value; @@ -61,7 +59,7 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO return mslDocument; } - + public static CSDLContainer IntegrateMSLInCSDLContainer(CSDLContainer csdlContainer, SSDLContainer ssdlContainer, XElement edmxRuntime) { XElement mappingsElement = edmxRuntime.Element(XName.Get("Mappings", edmxNamespace.NamespaceName)); @@ -263,10 +261,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO } } - #endregion - - #region Write - public static XElement Write(EDM edm) { CSDLContainer csdlContainer = edm.CSDLContainer; @@ -533,10 +527,6 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO new XAttribute("ColumnName", result.Value)); } } - - #endregion - - #endregion } #region Extension methods @@ -560,6 +550,11 @@ namespace ICSharpCode.Data.EDMDesigner.Core.IO return element; } + + public static bool HasEntityTypeMappingChildElement(this XElement entitySetMapping) + { + return entitySetMapping.Elements().Any(e => e.Name.LocalName == "EntityTypeMapping"); + } } #endregion diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index f6cdf35023..c73aea0e6b 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -149,7 +149,8 @@ namespace ICSharpCode.SharpDevelop if (openedFileDict.ContainsKey(newName)) { OpenedFile oldFile = openedFileDict[newName]; if (oldFile.CurrentView != null) { - oldFile.CurrentView.WorkbenchWindow.CloseWindow(true); + if (oldFile.CurrentView.WorkbenchWindow != null) + oldFile.CurrentView.WorkbenchWindow.CloseWindow(true); } else { throw new ArgumentException("there already is a file with the newName"); }