Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:22:31+00:00 2026-06-02T10:22:31+00:00

In a function I pass a list of related values and loop over them

  • 0

In a function I pass a list of related values and loop over them to save changes in the database. All works well until 2 or more people use the same page to update different entities .Then only that data gets saved for which the changes were made more recently.

   public bool UpdatePermanentDifferenceBL(List<PermanentDifferenceProperties>                                permDiffDetails)
   {
       try
       {
           int permanentDifferenceID=0;
           int taxEntityID = 0;
           int mapid = 0;

           //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
           //{


                  Topaz.DAL.PermanentDifference permDiff;


                      for (int i = 0; i < permDiffDetails.Count; i++)
                      {

                          if ((bool)(HttpContext.Current.Session[GlobalConstant.currentDataSet]) == true && (int)(HttpContext.Current.Session[GlobalConstant.snapShotID]) == 0)
                          {
                              using (var ctx = new TopazDbContainer())
                              {

                                   try
                                 {
                                      permanentDifferenceID = permDiffDetails[i].PermanentDifferenceID;
                                      taxEntityID = permDiffDetails[i].TaxEntityID;
                                      mapid = permDiffDetails[i].MapID;

                                      permDiff = new Topaz.DAL.PermanentDifference();


                                      permDiff = ctx.PermanentDifference.Where(p => p.PermanentDifferenceID == permanentDifferenceID && p.TaxEntityID == taxEntityID && p.MapID == mapid).SingleOrDefault();
                                      permDiff.Business = permDiffDetails[i].Business;
                                      permDiff.Interest = permDiffDetails[i].Interest;
                                      permDiff.Corporate = permDiffDetails[i].Corporate;
                                      permDiff.UnallocatedTax = permDiffDetails[i].UnallocatedTax;
                                      permDiff.Total = permDiffDetails[i].Total;
                                      permDiff.ModifiedBy = permDiffDetails[i].ModifiedBy;
                                      permDiff.ModifiedDate = DateTime.Now;
                                      ctx.SaveChanges();

                              }
                           catch (System.Data.OptimisticConcurrencyException ex)
                              {
                                    permanentDifferenceID = permDiffDetails[i].PermanentDifferenceID;
                                    taxEntityID = permDiffDetails[i].TaxEntityID;
                                    mapid = permDiffDetails[i].MapID;
                                    permDiff = new Topaz.DAL.PermanentDifference();                                  
                                    ctx.Refresh(System.Data.Objects.RefreshMode.StoreWins, permDiff);
                                    permDiff = ctx.PermanentDifference.Where(p => p.PermanentDifferenceID == permanentDifferenceID && p.TaxEntityID == taxEntityID && p.MapID == mapid).SingleOrDefault();
                                    permDiff.Business = permDiffDetails[i].Business;
                                    permDiff.Interest = permDiffDetails[i].Interest;
                                    permDiff.Corporate = permDiffDetails[i].Corporate;
                                    permDiff.UnallocatedTax = permDiffDetails[i].UnallocatedTax;
                                    permDiff.Total = permDiffDetails[i].Total;
                                    permDiff.ModifiedBy = permDiffDetails[i].ModifiedBy;
                                    permDiff.ModifiedDate = DateTime.Now;
                                    ctx.SaveChanges();
                                  }


                              }
                      }


                      //ctx.ContextOptions.UseLegacyPreserveChangesBehavior = true;



                  }



               //}


           //using (UnitOfWork uow = new UnitOfWork())
           //{
           //    for (int i = 0; i < permDiffDetails.Count; i++)
           //    {
           //        if ((bool)(HttpContext.Current.Session[GlobalConstant.currentDataSet]) == true && (int)(HttpContext.Current.Session[GlobalConstant.snapShotID]) == 0)
           //        {
           //            Repository.PermanentDifferenceRepository pDiffRepo = new Repository.PermanentDifferenceRepository(uow);
           //            Topaz.DAL.PermanentDifference permDiff = pDiffRepo.GetByEntityId(permDiffDetails[i].PermanentDifferenceID, permDiffDetails[i].TaxEntityID, permDiffDetails[i].MapID);


           //            permDiff.Business = permDiffDetails[i].Business;
           //            permDiff.Interest = permDiffDetails[i].Interest;
           //            permDiff.Corporate = permDiffDetails[i].Corporate;
           //            permDiff.UnallocatedTax = permDiffDetails[i].UnallocatedTax;
           //            permDiff.Total = permDiffDetails[i].Total;
           //            permDiff.ModifiedBy = permDiffDetails[i].ModifiedBy;
           //            permDiff.ModifiedDate = DateTime.Now;
           //            pDiffRepo.ApplyChanges(permDiff);

           //        }

           //        else
           //        {
           //            int snapshotID = (int)(HttpContext.Current.Session[GlobalConstant.snapShotID]);
           //            SnapShotPermanentDifferenceRepository pDiffRepo = new SnapShotPermanentDifferenceRepository(uow);
           //            SnapShotPermanentDifference permDiff = pDiffRepo.GetByEntityId(permDiffDetails[i].PermanentDifferenceID, permDiffDetails[i].TaxEntityID, permDiffDetails[i].MapID,snapshotID);

           //            permDiff.SnapshotID = snapshotID;
           //            permDiff.Business = permDiffDetails[i].Business;
           //            permDiff.Interest = permDiffDetails[i].Interest;
           //            permDiff.Corporate = permDiffDetails[i].Corporate;
           //            permDiff.UnallocatedTax = permDiffDetails[i].UnallocatedTax;
           //            permDiff.Total = permDiffDetails[i].Total;
           //            permDiff.ModifiedBy = permDiffDetails[i].ModifiedBy;
           //            permDiff.ModifiedDate = DateTime.Now;
           //            pDiffRepo.ApplyChanges(permDiff);


           //        }
           //    }
           //    uow.SaveChanges();
               return true;
           }
       catch (Exception ex)
       {
           TopazErrorLogs.AddTopazErrorLogBL(ex, 1, 1);
           throw new TopazCustomException(GlobalConstant.errorMessage);

       }

   }

Any urgent assistance is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:22:44+00:00Added an answer on June 2, 2026 at 10:22 am

    Apologies all the viewstate and to some extent session was the culprit and not EntityFramework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass a property list of a class to a function. with
I'm trying to pass a list to a function in Lisp, and change the
I need to pass a list to a KornShell (ksh) function, something like this:
Is there a way to pass a list as a function argument to eval()
I am trying to iterate over all objects in a List with array subscription
In python the * allows me to pass a list as function parameters: def
i would like to assign new values to the list i pass to my
In a function that expects a list of items, how can I pass a
I have class Foo(): function bar(): pass function foobar(): pass Rather than executing each
I'm trying to make simple script using jquery $post function to pass data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.