Suppose below app service
public void CreatePerson(CreatePersonInput input)
{
var person = new Person { Name = input.Name, EmailAddress = input.EmailAddress };
if(_personRepository.Any().Count()>10)
throw new UserFriendlyExceptio("some error message");
_personRepository.Insert(person);
}
based on Abp documentation application service is already implement unitOfWork. but when I send two or more request continuously, exception not fire
8 Answer(s)
-
0
Does anyone have any idea??
-
0
I did not understand your question. I also did not understand this code:
_personRepository.Any().Count()
Why no just:
_personRepository.Count()
???
-
0
i'm so sorry. this code
_personRepository.Any().Count()
is wrong . it is
_personRepository.Count()
I mean that person's number can not be grater than for example 10.
-
0
Hi,
Why do you expect an exception in this case ?
-
0
I want to person count can not be bigger than 10
-
0
Your code seems correct and simple. If it does not work, that means repository.Count() does not work. Can you try to get Count and get list of people to understand if it can not get some people?
-
0
suppose line
Syste.Threading.Thread.Sleep(2000);
added before line
_personRepository.Insert(person);
what happen if client send request rapidly to application service method?
-
0
If your case is that, why you just add all lines in a lock statement to provide thread synchronization?