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.

Database.Update

In this lesson we will learn how to update and persist data.
M# provides an Update() method to update records in the database. Each time an object is updated, the same events as for Database.Save are raised: Validate(), OnSaving(), OnSaved().

Overloads

There are two overload for the Update method, one for updating one instance and the other for updating a list of instances.

Overload 1: One instance

This overload allows you to update the properties of one entry.

Example:

Overload 2: Multiple instances

This overload allows you to update the properties of a list of entries in one line and inside a transaction scope. If one update fails all updates will be rolled back.

Example:

Multiple properties

You can easily update many properties at the same time like this: