Beispiel #1
0
        /// <summary>
        /// Removes stale unwanted records.
        /// </summary>
        /// <param name="cfMdl">Statements obtained from external data source</param>
        /// <param name="oldcfML">Statements in database.</param>
        /// <returns></returns>
        private async Task RemoveUnwantedRecords(List <CompanyFinancialsMd> cfMdl, List <CompanyFinancialsMd> oldcfML)
        {
            CompanyFinancialsMd recordsToBeDeleted;

            //Do statement is sufficient here. 99% of the time there will not be more than one
            //record to delete. Why create a list that will contain 0 or 1 elements always.
            do
            {
                recordsToBeDeleted = (from o in oldcfML
                                      where !cfMdl.Any(c => c.FYear == o.FYear)
                                      select o).FirstOrDefault();
                if (recordsToBeDeleted != null)
                {
                    await _dbconCompany.Remove(recordsToBeDeleted.Id);

                    oldcfML.Remove(recordsToBeDeleted);
                }
            } while (recordsToBeDeleted != null);
        }