Step 3: Write Code

Now your framework is generated and you are ready to write your custom code. Add the a reference to your generated framework to your UI project. Then add a using statement to your namespace within your ASPX code behind and you are ready to go. Here is some sample code for working with an entity generated by the Kinetic Framework.. Let's say you generated some code from the Adventure Works sample database.

Get a collection contacts
EntityList<Contact> contacts = AdventureWorks.Business.Contact.GetContacts();


Get one contact
Contact contact = AdventureWorks.Business.Contact.GetContact(1);


Create a new contact
Contact contact = AdventureWorks.Business.Contact.CreateContact();
contact.FirstName = "my first";
contact.LastName = "user";
contact.Save();


Update a contact
Contact contact = AdventureWorks.Business.Contact.GetContact(1);
contact.FirstName = "my first";
contact.LastName = "user";
contact.Save();

Note: All saves are recursive so if you update or add child objects they will also be updated / added when you save the parent object.

Delete a contact
Contact contact = AdventureWorks.Business.Contact.GetContact(1);
contact.Delete();


Those are the basics. Review the advanced topics area to get more insights into how to get the most out of the Kinetic Framework.

Last edited Jul 17, 2008 at 1:50 AM by RossCode, version 17

Comments

No comments yet.