public void GroupsMultipleObjectsAsChildItems() { var dicts = new[] { new Dictionary <string, object> { { "foo", "Foo1" }, { "__with1__bar__quux", "Quux1" }, { "__with1__wibble__wobble", "Wobble1" } }, }; var test = new EagerLoadingEnumerable(dicts).ToList(); Assert.AreEqual(1, test.Count); var actual = test[0]; Assert.AreEqual("Foo1", actual["foo"]); var bar = actual["bar"] as IDictionary <string, object>; Assert.NotNull(bar); Assert.AreEqual("Quux1", bar["quux"]); var wibble = actual["wibble"] as IDictionary <string, object>; Assert.NotNull(wibble); Assert.AreEqual("Wobble1", wibble["wobble"]); }
public IEnumerable<IDictionary<string, object>> RunQuery(SimpleQuery query, out IEnumerable<SimpleQueryClauseBase> unhandledClauses) { IEnumerable<IDictionary<string, object>> result; if (query.Clauses.OfType<WithCountClause>().Any()) return RunQueryWithCount(query, out unhandledClauses); ICommandBuilder[] commandBuilders = GetQueryCommandBuilders(query, out unhandledClauses); IDbConnection connection = _adapter.CreateConnection(); if (_adapter.ProviderSupportsCompoundStatements || commandBuilders.Length == 1) { result = CommandBuilder.CreateCommand( _adapter.ProviderHelper.GetCustomProvider<IDbParameterFactory>(_adapter.SchemaProvider), commandBuilders, connection).ToEnumerable(_adapter.CreateConnection); } else { result = commandBuilders.SelectMany(cb => cb.GetCommand(connection).ToEnumerable(_adapter.CreateConnection)); } if (query.Clauses.OfType<WithClause>().Any()) { result = new EagerLoadingEnumerable(result); } return result; }
public void GroupsObjectAsChildItem() { var dict = new Dictionary<string, object> { {"foo", "Foo1"}, {"__with1__bar__quux", "Quux1"} }; var test = new EagerLoadingEnumerable(new[] {dict}).ToList(); Assert.AreEqual(1, test.Count); var actual = test[0]; Assert.AreEqual("Foo1", actual["foo"]); var bar = actual["bar"] as IDictionary<string, object>; Assert.NotNull(bar); Assert.AreEqual("Quux1", bar["quux"]); }
public void GroupsObjectAsChildItem() { var dict = new Dictionary <string, object> { { "foo", "Foo1" }, { "__with1__bar__quux", "Quux1" } }; var test = new EagerLoadingEnumerable(new[] { dict }).ToList(); Assert.AreEqual(1, test.Count); var actual = test[0]; Assert.AreEqual("Foo1", actual["foo"]); var bar = actual["bar"] as IDictionary <string, object>; Assert.NotNull(bar); Assert.AreEqual("Quux1", bar["quux"]); }
public void GroupsMultipleObjectsAsChildItems() { var dicts = new[] { new Dictionary<string, object> { {"foo", "Foo1"}, {"__with1__bar__quux", "Quux1"}, {"__with1__wibble__wobble", "Wobble1"} }, }; var test = new EagerLoadingEnumerable(dicts).ToList(); Assert.AreEqual(1, test.Count); var actual = test[0]; Assert.AreEqual("Foo1", actual["foo"]); var bar = actual["bar"] as IDictionary<string, object>; Assert.NotNull(bar); Assert.AreEqual("Quux1", bar["quux"]); var wibble = actual["wibble"] as IDictionary<string, object>; Assert.NotNull(wibble); Assert.AreEqual("Wobble1", wibble["wobble"]); }