public XDocument ToXml() { return(new XDocument( new XElement("DataContext", new XAttribute("Name", this.Name ?? ""), new XAttribute("Namespace", this.Namespace), new XAttribute("CodePath", this.CodePath ?? ""), Imports.Select(ic => new XElement("Import", new XAttribute("Path", ic.RelativePath))), Schemas.SortDependencies().Where(s => !s.IsExternal).Select(s => s.ToXml()) ) )); }