-
Notifications
You must be signed in to change notification settings - Fork 1
Performing CRUD operations
Eros Stein edited this page Jan 8, 2017
·
9 revisions
Here we'll see how to perform CRUD operations using the library.
- Create
- Update
- Get
- Delete
We can add records to the database using a few different approaches:
using (var ctx = new AppContext(new AppConfiguration()))
{
public AccountViewModel Add(AccountViewModel data)
{
var account = ctx.Add(new Account
{
CreationDate = DateTime.Now,
Name = data.Name
});
ctx.Save(false);
return account.ToViewModel();
}
}The above code can also be written this way:
using (var ctx = new AppContext(new AppConfiguration()))
{
public AccountViewModel Add(AccountViewModel data)
{
var account = ctx.Add<Account>();
account.CreationDate = DateTime.Now;
account.Name = data.Name;
ctx.Save(false);
return account.ToViewModel();
}
}