Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created June 1, 2010 22:17
Show Gist options
  • Save jfromaniello/421602 to your computer and use it in GitHub Desktop.
Save jfromaniello/421602 to your computer and use it in GitHub Desktop.
private dynamic CreatePerson()
{
dynamic person = new ExpandoObject();
//Set the two commands.
person.CancelCommand = new RelayCommand(() =>
{
person.FirstName = "[First name ...]";
person.LastName = "[Last name ...]";
});
person.SaveCommand = new RelayCommand(() =>
{
using (var s = sessionFactory.OpenSession())
using (var tx = s.BeginTransaction())
{
var obj = ((ExpandoObject)person).ToDictionary(k => k.Key, k => k.Value);
s.Save("Person", obj);
tx.Commit();
}
});
//set the default values.
person.CancelCommand.Execute(null);
return person;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment