Esempio n. 1
0
        public async Task <User> UpdateUserSomeProperties(User user)
        {
            user = new User
            {
                Email     = "*****@*****.**",
                UserId    = 1,
                FirstName = "firstname" + Guid.NewGuid(),
                LastName  = "lastname" + DateTime.Now.ToString("o"),
                UserName  = "******"
            };

            await Task.Run(() =>
            {
                _userRepository.UpdateSpecficProperty(user, new Expression <Func <User, object> >[] { });
                _userRepository.SaveChanges();
            });

            var usr1 = await _userRepository.GetAll(g => g.UserId == 1).FirstOrDefaultAsync();

            await Task.Run(() =>
            {
                usr1.FirstName = "first";
                usr1.LastName  = "last";
                usr1.Email     = "xxx";
                usr1.UserName  = "******";

                _userRepository.UpdateSpecficProperty(usr1, o => o.LastName, o => o.FirstName);
                _userRepository.SaveChanges();
            });

            var usr2 = await _userRepository.GetAll(g => g.UserId == 1).FirstOrDefaultAsync();

            return(usr2);
        }