Delete Data
Deleting Data Programmatically
Before you begin, make sure you have created a global data type "Demo.User" with one field of the String
type named "Name" and some data or update the code in the sample to refer to an actual data type and its fields .
Sample:
using System.Linq; using Composite.Data; namespace Demo { public class Class3 { public static void DeleteData(string userName) { using (DataConnection connection = new DataConnection()) { Demo.User myUser = (from d in connection.Get<Demo.User>() where d.Name == userName select d).First(); connection.Delete<Demo.User>(myUser); } } } }
In this sample, we use DataConnection
to query for a Demo.User (Get
) with a specific name (Name
) and delete it from the CMS Data store (Delete
).
Read more on Composite.Data.DataConnection and its member methods
Please also see How to Delete Data.