Created
February 7, 2011 18:42
-
-
Save SzymonPobiega/814922 to your computer and use it in GitHub Desktop.
This file contains 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
[Test] | |
public void NHibernate_allows_crud_operations() | |
{ | |
Create(); | |
Read(); | |
Update(); | |
Delete(); | |
} | |
private void Create() | |
{ | |
using (var session = OpenNamedSession("Create")) | |
{ | |
var customer = new Customer() | |
{ | |
FirstName = "John", | |
LastName = "Cleese" | |
}; | |
_customerId = session.Save(customer); | |
session.Flush(); | |
} | |
} | |
private void Read() | |
{ | |
using (var session = OpenNamedSession("Read")) | |
{ | |
var customer = session.Get<Customer>(_customerId); | |
Console.WriteLine("Hello, {0}!", customer.FirstName); | |
} | |
} | |
private void Update() | |
{ | |
using (var session = OpenNamedSession("Update")) | |
{ | |
var customer = session.Get<Customer>(_customerId); | |
customer.FirstName = "Graham"; | |
customer.LastName = "Chapman"; | |
session.Flush(); | |
} | |
} | |
private void Delete() | |
{ | |
using (var session = OpenNamedSession("Delete")) | |
{ | |
var customer = session.Get<Customer>(_customerId); | |
session.Delete(customer); | |
session.Flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment