public static IEnumerable <XElement> ReplaceCsdlNamespacesForEdmVersion(XElement[] csdls, EdmVersion edmVersion) { var edmNamespace = EdmLibCsdlContentGenerator.GetCsdlFullNamespace(edmVersion); for (int i = 0; i < csdls.Count(); ++i) { if (edmNamespace != csdls[i].Name.Namespace) { csdls[i] = XElement.Parse(csdls[i].ToString().Replace(csdls[i].Name.Namespace.NamespaceName, edmNamespace.NamespaceName)); } } return(csdls); }
public static string ReplaceCsdlNamespaceForEdmVersion(string csdl, EdmVersion edmVersion) { var edmNamespace = EdmLibCsdlContentGenerator.GetCsdlFullNamespace(edmVersion); var xmlReader = XmlReader.Create(new StringReader(csdl)); while (xmlReader.Read()) { if (xmlReader.Name == "Schema") { break; } } if (xmlReader.EOF) { throw new ArgumentException("{0} is not a well formed CSDL."); } return(csdl.Replace(xmlReader.NamespaceURI, edmNamespace.NamespaceName)); }