Created
April 9, 2013 17:57
-
-
Save shamp00/5347869 to your computer and use it in GitHub Desktop.
Example for http://stackoverflow.com/q/15904351/1077279
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
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