How to use addNew api in lightswitch

108 Views Asked by At

Now I started working on lightswith application but I can't achieve crud operation light through api addNew() method like as

screen.table.addNew()
1

There are 1 best solutions below

0
BobbyJ On

If you're using the HTML client, the function can be used in the following way for an entity set named Customers, with a string property named Name:

var customer = screen.Customers.addNew();
customer.Name = "TestCustomer";
myapp.activeDataWorkspace.ApplicationData.saveChanges();

Unless you're setting an entity that the framework will be saving (such as the element on an addEdit screen), you need to save it with the saveChanges or commitChanges functions.