Base solution for your next web application
Open Closed

Validation Errors Generated By AppService #5212


User avatar
0
greatsamps created

Hi,

In our application, we are checking some bits that require a database lookup (duplicates etc) during the method call to the Add/Update method on the AppServices. What i am looking to do is throw a detailed validation exception if something is incorrect.

I have found this link:

<a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Validating-Data-Transfer-Objects">https://aspnetboilerplate.com/Pages/Doc ... er-Objects</a>

but it is not clear how i can get hold of the validation context from an appservice.

Please advise.


2 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    If you want to make some DB requests in your DTO it's a very bad practice. You should do it in your Application Service method.

  • User Avatar
    0
    ismcagdas created
    Support Team

    You can throw AbpValidationException.