Created
June 1, 2010 22:17
-
-
Save jfromaniello/421602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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