The C in CRUD Silverlight:
- Create new Silverlight business application "CRUD"
- Add ADO.NET Entity Data Model to CRUD.web
- Select the db, the tables, build the project
- Add Domain Service Class to CRUD.web
- Select the tables and also select the allow editing option for the table "tname"
- Build the project
- Keep two textboxes "ID" and "NAME" on MainPage.xaml
- Keep a button "SAVE NEW RECORD" on MainPage.xaml
- Build
Add the following code
Partial Public Class MainPage Inherits UserControl Dim dserv As New DomainService1 //default methods generated Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click 'declare a table object Dim table As New tname 'assign values to fields table.ID = TextBox1.Text table.NAME = TextBox2.Text 'add table object entity dserv.tnames.Add(table) 'submit the changes, to make it permenant in the db dserv.SubmitChanges() End Sub
Record inserted
Is this the easiest way for having no side effects to add a new record? Is this the optimal way to add a new record?