This repository was archived by the owner on Oct 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Updates
Daniel Wertheim edited this page Nov 29, 2012
·
9 revisions
Updates the structure in the Structure, Indexes- and Uniques tables.
var item = new SimpleItem { Value = "A" };
Database.WriteOnce().Insert(item);
...
...
using (var session = Database.BeginSession())
{
var refetched = session.GetById<SimpleItem>(item.Id);
refetched.Value = "B";
session.Update(refetched);
}##Concurrency tokens From v10.0 you can now chose to include a concurrency token in your model. Read more about it here.
##Inline updates From v10.0 you can now do "inline updates" and also (optional) provide a proceed condition.
using(var session = db.BeginSession())
{
session.Update<Customer>(
id,
c => c.BonusPoints = bonusPointIncreasedEvent.NewValue);
}
//or
db.UseOnceTo().Update<Customer>(
id,
c => c.BonusPoints = bonusPointIncreasedEvent.NewValue);and with the proceed clause:
using(var session = db.BeginSession())
{
session.Update<Customer>(
id,
c => c.BonusPoints = bonusPointIncreasedEvent.NewValue,
c => bonusPointIncreasedEvent.Sequence > c.LastSequence);
}
//or
db.UseOnceTo().Update<Customer>(
id,
c => c.BonusPoints = bonusPointIncreasedEvent.NewValue,
c => bonusPointIncreasedEvent.Sequence > c.LastSequence);This is useful e.g. when using SisoDb in a concurrent and multithreaded environment like in a asynchronous CQRS solution, since it lets you keep down the update-scope and only update if it's a later message.