private static void StoreData(IObjectContainer container) { Pilot john = new Pilot("John", 42); Pilot joanna = new Pilot("Joanna", 45); Pilot jenny = new Pilot("Jenny", 21); Pilot rick = new Pilot("Rick", 33); container.Store(new Car(john, "Ferrari")); container.Store(new Car(joanna, "Mercedes")); container.Store(new Car(jenny, "Volvo")); container.Store(new Car(rick, "Fiat")); }
private static void CompareWithStoredObject(IObjectContainer container) { Console.WriteLine("Compare with existing object"); // #example: Compare with existing object Pilot pilot = container.Query <Pilot>()[0]; IQuery query = container.Query(); query.Constrain(typeof(Car)); // if the given object is stored, its compared by identity query.Descend("pilot").Constrain(pilot); IObjectSet carsOfPilot = query.Execute(); // #end example ListResult(carsOfPilot); }
private static void MixWithQueryByExample(IObjectContainer container) { Console.WriteLine("Mix with query by example"); // #example: Mix with query by example IQuery query = container.Query(); query.Constrain(typeof(Car)); // if the given object is not stored, // it will behave like query by example for the given object Pilot examplePilot = new Pilot(null, 42); query.Descend("pilot").Constrain(examplePilot); IObjectSet carsOfPilot = query.Execute(); // #end example ListResult(carsOfPilot); }
public Car(Pilot pilot, string name) { this.pilot = pilot; this.name = name; }
public void Evaluate(ICandidate candidate) { Pilot pilot = (Pilot)candidate.GetObject(); candidate.Include(pilot.Age % 2 != 0); }
private static void StoreData(IObjectContainer container) { Pilot john = new Pilot("John", 42); Pilot joanna = new Pilot("Joanna", 45); Pilot jenny = new Pilot("Jenny", 21); Pilot rick = new Pilot("Rick", 33); container.Store(new Car(john, "Ferrari")); container.Store(new Car(joanna, "Mercedes")); container.Store(new Car(jenny, "Volvo")); container.Store(new Car(rick, "Fiat")); BlogPost firstPost = new BlogPost("db4o", "Content about db4o"); firstPost.AddTags("db4o", ".net", "java", "database"); firstPost.AddMetaData("comment-feed-link", "localhost/rss"); firstPost.AddAuthors(new Author("John"), new Author("Jenny"), new Author("Joanna")); container.Store(firstPost); BlogPost secondPost = new BlogPost("cars", "Speedy cars"); secondPost.AddTags("cars", "fast"); secondPost.AddMetaData("comment-feed-link", "localhost/rss"); secondPost.AddMetaData("source", "www.wikipedia.org"); secondPost.AddAuthors(new Author("Joanna"), new Author("Jenny")); container.Store(secondPost); }