I want to apply queries on Boilerplate default tables in database. But boilerplate uses async methods. How to search in database by Boilerplate framework.
Asked
Active
Viewed 874 times
2 Answers
2
Could you elaborate your question?
I'm not sure what do you want to achieve.
If you uses IRepository you can use both synchronous and asynchronous methods by default.
If you're using asynchronous query and expecting immediate result you can use
If you have to wait for query results you can use Result property of Task. e.g.
var valueImWaitingFor = _repository.GetAllListAsync().Result;
Edit: Assuming that you want to update user under login you can use provided UserManager class.
var user = loginResult.User; // get your user object
user.Name = "New name"; // edit property
// use one of 3 proposed solutions.
var updatedUser = _userManager.Update(user);
var updatedUser1 = _userManager.UpdateAsync(user).ConfigureAwait(false);
var updatedUser2 = AsyncHelper.RunSync(()=>_userManager.UpdateAsync(user));
Even if you don't use UserManager you can run async call similar way using second and third option.

Pepek
- 97
- 9
-
Actually i want to update record in ABpUser table. and you know that It uses async methods. So how i can update a record Sir @Pepek – MMG Aug 28 '17 at 07:01
0
If you want to use async methods as sync methods then there's a helper class in ABP.
var records = AsyncHelper.RunSync(() => _repository.GetAllListAsync());

Alper Ebicoglu
- 8,884
- 1
- 49
- 55
-
-
1did you try @Pepek solution? i see that you've not tried to solve the problem on your own. first read the aspnetboilerplate docs. – Alper Ebicoglu Aug 28 '17 at 14:11