public void Test2() { var tree = new QueryRelationTree(); Expression <Func <EQBPerson, object> > AB = person => person.BestFriend.IdentityCard; Expression <Func <EQBPerson, object> > AAAA = person => person.BestFriend.BestFriend.BestFriend.BestFriend; Expression <Func <EQBPerson, object> > CD = person => person.CurrentOwnedVehicles.First().Wheels; Expression <Func <EQBPerson, object> > CE = person => person.CurrentOwnedVehicles.First().RoadworthyTests; //Input tree.AddNode(AB); tree.AddNode(AAAA); tree.AddNode(CD); tree.AddNode(CE); var results = tree.DeepFirstSearch(); //Output Assert.AreEqual("BestFriend", results[0][0]); Assert.AreEqual("BestFriend.IdentityCard", results[0][1]); Assert.AreEqual("BestFriend", results[1][0]); Assert.AreEqual("BestFriend.BestFriend", results[1][1]); Assert.AreEqual("BestFriend.BestFriend.BestFriend", results[1][2]); Assert.AreEqual("BestFriend.BestFriend.BestFriend.BestFriend", results[1][3]); Assert.AreEqual("CurrentOwnedVehicles", results[2][0]); Assert.AreEqual("CurrentOwnedVehicles.Wheels", results[2][1]); Assert.AreEqual("CurrentOwnedVehicles", results[3][0]); Assert.AreEqual("CurrentOwnedVehicles.RoadworthyTests", results[3][1]); }
public void Test1() { var tree = new QueryRelationTree(); Expression <Func <EQBPerson, object> > A = person => person.BestFriend; Expression <Func <EQBPerson, object> > AB = person => person.BestFriend.IdentityCard; Expression <Func <EQBPerson, object> > AA = person => person.BestFriend.BestFriend; Expression <Func <EQBPerson, object> > AAA = person => person.BestFriend.BestFriend.BestFriend; Expression <Func <EQBPerson, object> > AAAA = person => person.BestFriend.BestFriend.BestFriend.BestFriend; //Input tree.AddNode(A); tree.AddNode(AB); tree.AddNode(AA); tree.AddNode(AAA); tree.AddNode(AAAA); var results = tree.DeepFirstSearch(); //Output Assert.AreEqual("BestFriend", results[0][0]); Assert.AreEqual("BestFriend.IdentityCard", results[0][1]); Assert.AreEqual("BestFriend", results[1][0]); Assert.AreEqual("BestFriend.BestFriend", results[1][1]); Assert.AreEqual("BestFriend.BestFriend.BestFriend", results[1][2]); Assert.AreEqual("BestFriend.BestFriend.BestFriend.BestFriend", results[1][3]); }
private IFutureValue <T> ExecuteQueryTreeFutureValue <T>(Expression queryExpression) { var tree = new QueryRelationTree(); IFutureValue <T> result = null; foreach (var path in IncludePaths) { tree.AddNode(path); } var leafs = tree.GetLeafs(); leafs.Sort(); var expressions = leafs.Aggregate(new ExpressionInfo(queryExpression), FetchFromPath).GetExpressions(); var i = 0; foreach (var expression in expressions) { if (i == 0) { result = _queryProvider.ExecuteFutureValue <T>(expression); } else { _queryProvider.ExecuteFuture <T>(expression); } i++; } return(result); }
public void Test3() { var tree = new QueryRelationTree(); Expression <Func <EQBPerson, object> > AB = person => person.Identity; Expression <Func <EQBPerson, object> > CD = person => person.IdentityCard; //Input tree.AddNode(AB); tree.AddNode(CD); var results = tree.DeepFirstSearch(); //Output Assert.AreEqual("Identity", results[0][0]); Assert.AreEqual("IdentityCard", results[1][0]); }
private List <Expression> GetExpressions(Expression queryExpression) { IClassMetadata meta; var metas = Session.Factory.GetAllClassMetadata() .Select(o => o.Value) .Where(o => Type.IsAssignableFrom(o.MappedClass)) .ToList(); if (!metas.Any()) { throw new HibernateException($"Metadata for type '{Type}' was not found"); } if (metas.Count > 1) { meta = metas.FirstOrDefault(o => o.MappedClass == Type); if (meta == null) { throw new HibernateException( $"Unable to find the the correct candidate for type '{Type}'. Candidates: {string.Join(", ", metas.Select(o => o.MappedClass))}"); } } else { meta = metas.First(); } var tree = new QueryRelationTree(); foreach (var path in IncludePaths) { tree.AddNode(path); } var leafs = tree.GetLeafs(); leafs.Sort(); return(leafs.Aggregate(new ExpressionInfo(queryExpression, meta), FetchFromPath).GetExpressions()); }