public void AmbienceServerRunsWithSpecifiedOptions() { File.Delete("IntegrationTest.db"); ProcessTask task = StartAmbienceServer("/db:IntegrationTest.db /p:" + PortNumber + " /u:Test /pw:LetMeIn"); var config = new AmbienceClientConfiguration() { Port = PortNumber, Credential = new NetworkCredential("Test", "LetMeIn") }; AmbienceClient client = AmbienceClient.Connect(config); IAmbientDataContainer container = client.Container; container.DeleteAll(); container.Store(new Item() { Name = "foo", Value = 42 }); container.Store(new Item() { Name = "bar", Value = 40 }); Assert.AreEqual("foo", (from Item x in container where x.Value == 42 select x.Name).Single()); Assert.AreEqual(0, (from Item x in container where x.Value == 0 select x).Count()); task.Abort(); }
/// <summary> /// Obtains a query over a data container. /// </summary> /// <remarks> /// <para> /// Client code will not call this method directly. However, it turns out that /// the C# compiler will add an implicit call to this method when it attempts to /// select a value from the container using LINQ syntax. /// </para> /// </remarks> /// <typeparam name="T">The result type.</typeparam> /// <param name="container">The container.</param> /// <returns>The query object.</returns> public static IAmbientDataQuery <T> Cast <T>(this IAmbientDataContainer container) { var db4oContainer = (Db4oAmbientDataContainer)container; return(new Db4oAmbientDataQuery <T>(db4oContainer.Inner.Cast <T>())); }