Loading large amounts of data into a List collection of business objects from Oracle

leadicemelf

New Member
I need a way to optimize the data retrieval of millions of records from an Oracle database into a List of custom business object. The data that is being returned from Oracle is in XML format and I need a way to serialize it into a List of business objects.The code I wrote is working properly, however, it is taking a long time to execute during the loading of the XML into memory, specifically when the code hits the line:\[code\]var xDoc = XDocument.Load(xmlReader); \[/code\]Code : \[code\]//Custom Business object public class AccountType { public int AccountTypeID { get; set; } public string AccountCode { get; set; } public string BookType { get; set; } public int Status { get; set; } }//Code that retrieves data from Oracle DB using (OracleConnection objOracleConnection = new OracleConnection(strConnectionString)) { using (OracleCommand orclCmd = objOracleConnection.CreateCommand()) { try { orclCmd.CommandText = strXMLSQL; orclCmd.BindByName = true; orclCmd.XmlCommandType = OracleXmlCommandType.Query; orclCmd.XmlQueryProperties.RootTag = "AccountData"; orclCmd.XmlQueryProperties.RowTag = "ROW"; objOracleConnection.Open(); XmlReader xmlReader = orclCmd.ExecuteXmlReader(); var xDoc = XDocument.Load(xmlReader); List<AccountType> accountTypes = (from data in xDoc.Root.Elements("ROW") select new AccountType { AccountTypeID = data.GetIntXMLElementValue("ACCOUNTTYPEID"), AccountCode = data.GetStringXMLElementValue("ACCOUNTCODE"), BookType = data.GetStringXMLElementValue("BOOKTYPE"), Status = data.GetIntXMLElementValue("STATUS") }).ToList(); } catch (OracleException oracleEx) { throw oracleEx; } catch (Exception generalEx) { throw generalEx; } finally { objOracleConnection.Close(); } }\[/code\]Any help would be greatly appreciated.Thanks!
 
Back
Top