EF 请求数据是缓存 求大神解释

8/10/2015来源:ASP.NET技巧人气:2406

EF 请求数据是缓存 求大神解释

//
//AliexPRessEntities MyaliexpressEntities  为了事物一致性 在别的方法里面传过来的 实质还是 ( AliexpressEntities aliexpressEntities = new AliexpressEntities();)
和 userBll.GetUser 方法里面的一样
   public YH_AmountAccount AmountAccountSaveChanges(AliexpressEntities MyaliexpressEntities, int amountAccounUserId, string transactionRemark, int transactionType, string transactionNumber, decimal? transactionAmount, decimal? transactionAmountMMB)        {            YH_AmountAccount AmountAccount = new YH_AmountAccount();            YH_UserBLL userBll = new YH_UserBLL();            var getuser = userBll.GetUser(amountAccounUserId);   //为什么  这里是 51.2 (正确 )            var userNow = MyaliexpressEntities.YH_User.Where(p => p.userId == amountAccounUserId).Single();   //这里是 63.8 (还是之前的数据)                         AmountAccount.createTime = DateTime.Now;            AmountAccount.isActive = true;            AmountAccount.createUserId = userNow.userId;            AmountAccount.amountAccounUserId = userNow.userId;            AmountAccount.transactionRemark = transactionRemark;            AmountAccount.transactionType = transactionType; //(transactionType 1发布任务 2删除任务 3完成任务 4账户充值)            AmountAccount.transactionNumber = transactionNumber;            AmountAccount.initialAmount = userNow.Balance + userNow.BalanceLocked;            AmountAccount.initialAmountMMB = userNow.MMCoin + userNow.MMCoinLocked;            AmountAccount.transactionAmount = transactionAmount;            AmountAccount.transactionAmountMMB = transactionAmountMMB;            AmountAccount.accountBalance = AmountAccount.initialAmount - AmountAccount.transactionAmount;            AmountAccount.accountBalanceMMB = AmountAccount.initialAmountMMB - AmountAccount.transactionAmountMMB;            userNow.MMCoin = AmountAccount.accountBalanceMMB - userNow.MMCoinLocked;            userNow.Balance = AmountAccount.accountBalance - userNow.BalanceLocked;            if (userNow.Balance < 0)            {                throw new Exception("您账户的可用余额不足,请充值!");            }            return AmountAccount;        }

  

userBll.GetUser 方法namespace Aliexpress.BLL{    public class YH_UserBLL    {        AliexpressEntities aliexpressEntities = new AliexpressEntities();                 public YH_User GetUser(int userId)        {            var user = aliexpressEntities.YH_User.Where(p => p.userId == userId&&p.isActive==true).SingleOrDefault();            return user;        }    }}

//调试数据