コード例 #1
0
        public static XDocument WriteXDocument(EDMView edmView)
        {
            if (edmView.EDM.IsEmpty)
            {
                return(WriteXDocument(null, null, null, null));
            }
            XElement ssdlElement     = SSDLIO.WriteXElement(edmView.EDM.SSDLContainer);
            XElement csdlElement     = CSDLIO.Write(edmView.EDM.CSDLContainer);
            XElement mslElement      = MSLIO.Write(edmView.EDM);
            XElement designerElement = DesignerIO.Write(edmView);

            return(WriteXDocument(ssdlElement, csdlElement, mslElement, designerElement));
        }
コード例 #2
0
        private static EDM Read(XElement edmx, Action <XElement> readMoreAction)
        {
            XElement edmxRuntime = edmx.Element(XName.Get("Runtime", edmxNamespace.NamespaceName));

            SSDLContainer ssdlContainer = SSDLIO.ReadXElement(edmxRuntime);
            CSDLContainer csdlContainer = CSDLIO.ReadXElement(edmxRuntime);
            XElement      edmxDesigner  = edmx.Element(XName.Get("Designer", edmxNamespace.NamespaceName));

            if (ssdlContainer == null && csdlContainer == null)
            {
                return(new EDM());
            }

            EDM edm = new EDM()
            {
                SSDLContainer = ssdlContainer,
                CSDLContainer = MSLIO.IntegrateMSLInCSDLContainer(csdlContainer, ssdlContainer, edmxRuntime),
            };

            if (edmxDesigner != null)
            {
                if (edmxDesigner.Element(XName.Get("Connection", edmxNamespace.NamespaceName)) != null)
                {
                    edm.DesignerProperties = edmxDesigner.Element(XName.Get("Connection", edmxNamespace.NamespaceName)).Element(XName.Get("DesignerInfoPropertySet", edmxNamespace.NamespaceName)).Elements(XName.Get("DesignerProperty", edmxNamespace.NamespaceName)).Select(e => new DesignerProperty {
                        Name = e.Attribute("Name").Value, Value = e.Attribute("Value").Value
                    });
                }

                if (edmxDesigner.Element(XName.Get("Options", edmxNamespace.NamespaceName)) != null)
                {
                    edm.EDMXDesignerDesignerProperties = edmxDesigner.Element(XName.Get("Options", edmxNamespace.NamespaceName)).Element(XName.Get("DesignerInfoPropertySet", edmxNamespace.NamespaceName)).Elements(XName.Get("DesignerProperty", edmxNamespace.NamespaceName)).Select(e => new DesignerProperty {
                        Name = e.Attribute("Name").Value, Value = e.Attribute("Value").Value
                    });
                }

                if (edmxDesigner.Element(XName.Get("Diagrams", edmxNamespace.NamespaceName)) != null)
                {
                    edm.EDMXDesignerDiagrams = edmxDesigner.Element(XName.Get("Diagrams", edmxNamespace.NamespaceName)).Elements(XName.Get("Diagram", edmxNamespace.NamespaceName));
                }
            }

            readMoreAction(edmx);
            return(edm);
        }