M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

Validation Based on Insert / Update

This tutorial explains handling different validation rules between two states of an instance i.e. new or existing. We often need to write some business validation rules when a new instance is saved and when the instance is updated. M# allows you to write distinguished business validation rule for an insert and update phase of an entity instance using “IsNew” property implemented in the base abstract “Entity” class. All entities created in M# inherit this base class (For more information on “IsNew” property, please read tutorial The Role of Is New).

As explained in the introduction tutorial, you should always write your custom validation in “Validate” method so, here in this tutorial we will use “IsNew” property to split validation based on insert and update as shown below