Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Check that entity exists before Update or Delete

$
0
0
Hi guys,

how can I check that entity itself exists before executing Update or Delete?

I tried using something like the code below, but getting an error "Property name must be specified". How to implement such logic?
   RuleFor(x=>x).Must(ExistsInDatabase).WithMessage("Attempt to work with nonexistent entity");

    private bool ExistsInDatabase(MyClass myClassInstance)
    {

         if (myClassInstance == null)
               return false;

         return true;

       }

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>