问题
I am working with ASP.Net Boilerplate. I want to send isActive=true
to the AbpUser
table when a user is confirmed by email. How can I access the database and do a query on that?
As you know Boilerplate doesn't provide entity classes so I am working with extensions on those classes. I don't know how queries on those classes access the database. Any idea?
回答1:
I wrote a sample code to show you how you can update a field of user with IRepository.
public interface IUserAppService: IApplicationService
{
void ActivateUser(int userId);
}
public class UserAppService : IUserAppService
{
private readonly IRepository<User, long> _userRepository;
public UserEmailer(IRepository<User, long> userRepository)
{
_userRepository = userRepository;
}
public void ActivateUser(int userId)
{
var user = _userRepository.Get(userId);
user.IsActive = true;
_userRepository.Update(user);
}
}
来源:https://stackoverflow.com/questions/45912587/asp-net-boilerplate-how-to-update-a-record-in-existing-tables-in-database-usi