static System.Data.Linq.Mapping.MappingSource GetMapping() { System.Reflection.Assembly ass = System.Reflection.Assembly.GetAssembly(typeof(MutiBaseDataContext)); System.IO.Stream s = ass.GetManifestResourceStream("lib.bwa.bigWebDesk.LinqBll.DataContext.LinqDB.xml"); System.Data.Linq.Mapping.XmlMappingSource ms = System.Data.Linq.Mapping.XmlMappingSource.FromStream(s); return(ms); }
public static EmailBounceBackDataContext GetDataContext(string CNN_STRING, string tableName) { // Get the .xml file into memory //Stream ioSt = Assembly.GetExecutingAssembly() // .GetManifestResourceStream("Documents.xml"); XElement xe = XElement.Load(XmlReader.Create("Documents.xml")); // Replace the table name value in memory var tableElements = xe.Elements().AsQueryable().Where(e => e.Name.LocalName.Equals("Table")); foreach (var t in tableElements) { foreach (var col in t.Descendants().Where(x => x.Name.LocalName == "Column" && x.Name == "PDFFilePath")) { XAttribute name = col.Attributes().FirstOrDefault(a => a.Name.LocalName == "Name"); name.Value = "PDFFilePath"; } //var nameAttribute = t.Attributes().Where(a => a.Name.LocalName.Equals("Name")); //foreach (var a in nameAttribute) //{ // if (a.Value.Equals("dbo.Documents")) // { // a.Value = a.Value.Replace("Documents", tableName); // } //} } // Obtain and return the dynamic DataContext System.Data.Linq.Mapping.XmlMappingSource source = System.Data.Linq.Mapping.XmlMappingSource.FromXml(xe.ToString()); return(new EmailBounceBackDataContext(CNN_STRING, source)); }