public void SimpleReferenceTest() { var store = new SQLiteDataStore("simpleReferenceTest.db"); store.AddType <Author>(); store.AddType <Book>(); store.CreateOrUpdateStore(); // insert an author var dumas = new Author() { Name = "Alexadre Dumas" }; store.Insert(dumas); // insert a couple books. // note that we're inserting the foreign key value store.Insert( new Book() { AuthorID = dumas.ID, Title = "The Count of Monte Cristo" }); store.Insert( new Book() { AuthorID = dumas.ID, Title = "The Three Musketeers" }); // now get the authors back, telling ORM to fill the references var authors = store.Select <Author>(true).ToArray(); // at this point you will have 1 Author instance, with the Books property hydrated and containing two Book instances }
public void SimpleReferenceTest2() { var store = new SQLiteDataStore("simpleReferenceTest.db"); store.AddType <Location>(); store.AddType <Position>(); store.CreateOrUpdateStore(); var position1 = new Position() { Description = "Position 1" }; store.Insert(position1); store.Insert( new Location() { Description = "Description A", positionId = position1.positionId }); var positions = store.Select <Position>(true).ToArray(); }