public static void StoreFirstCar(IObjectContainer db) { Car car1 = new Car("Ferrari"); Pilot pilot1 = new Pilot("Michael Schumacher", 100); car1.Pilot = pilot1; db.Store(car1); }
public static void RetrieveCarQBE(IObjectContainer db) { SensorReadout protoReadout = new SensorReadout(new double[] { 0.6, 0.2 }, DateTime.MinValue, null); IList protoHistory = new ArrayList(); protoHistory.Add(protoReadout); Car protoCar = new Car(null, protoHistory); IObjectSet result = db.QueryByExample(protoCar); ListResult(result); }
public static void StoreSecondCar(IObjectContainer db) { Pilot pilot2 = new Pilot("Rubens Barrichello", 99); Car car2 = new Car("BMW"); car2.Pilot = pilot2; car2.Snapshot(); car2.Snapshot(); db.Store(car2); }
public static void StoreCars(IObjectContainer db) { Pilot pilot1 = new Pilot("Michael Schumacher", 100); Car car1 = new Car("Ferrari"); car1.Pilot = pilot1; car1.Snapshot(); db.Store(car1); Pilot pilot2 = new Pilot("Rubens Barrichello", 99); Car car2 = new Car("BMW"); car2.Pilot = pilot2; car2.Snapshot(); car2.Snapshot(); db.Store(car2); }
public SensorReadout(double[] values, DateTime time, Car car) { _values = values; _time = time; _car = car; }
public static void UpdateCollection() { IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration(); config.Common.ObjectClass(typeof(Car)).CascadeOnUpdate(true); using(IObjectContainer db = Db4oEmbedded.OpenFile(config, YapFileName)) { IQuery query = db.Query(); query.Constrain(typeof (Car)); IObjectSet result = query.Descend("_history").Execute(); IList history = (IList) result.Next(); history.RemoveAt(0); db.Store(history); Car proto = new Car(null, null); result = db.QueryByExample(proto); foreach (Car car in result) { foreach (object readout in car.History) { Console.WriteLine(readout); } } } }
public bool Match(Car car) { foreach (SensorReadout sensor in car.History) { if (Array.IndexOf(sensor.Values, 0.3) > -1 && Array.IndexOf(sensor.Values, 0.1) > -1) { return true; } } return false; }