Skip to content

Instantly share code, notes, and snippets.

@shamp00
Created April 9, 2013 17:57
Show Gist options
  • Save shamp00/5347869 to your computer and use it in GitHub Desktop.
Save shamp00/5347869 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
namespace XpoConsoleApplication1
{
class Program
{
public class Photo : XPObject
{
public Photo(Session session)
: base(session)
{ }
private string _Description;
public string Description
{
get
{ return _Description; }
set
{ SetPropertyValue("Description", ref _Description, value); }
}
}
static void Main(string[] args)
{
XpoDefault.DataLayer = new SimpleDataLayer(new InMemoryDataStore());
using (UnitOfWork uow = new UnitOfWork())
{
var photo = new Photo(uow);
photo.Description = "Something";
// create a new photo and save it
uow.CommitChanges();
if (photo.Description != "Something")
throw new Exception("This should not happen");
}
using (UnitOfWork uow = new UnitOfWork())
{
var photos = new XPCollection<Photo>(uow);
photos[0].Description = "Something new";
uow.CommitTransaction();
if (photos[0].Description != "Something new")
throw new Exception("This should not happen");
}
Console.WriteLine("All ok");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment