/// <summary> /// Finds a collection of entities with the specified query. /// </summary> /// <typeparam name="TEntity">The type of the entity.</typeparam> /// <param name="query">The query.</param> /// <returns></returns> public virtual async Task <IEnumerable <TEntity> > Where(Expression <Func <TEntity, bool> > query) { string name = query.Parameters[0].Name; TEntity entity = (TEntity)Activator.CreateInstance(query.Parameters[0].Type); Expression <Func <TEntity, bool> > newQuery = PredicateRewriter.Rewrite(query, "e"); return(await client.Cypher .Match("(e:" + entity.Label + ")") .Where(newQuery) .Return(e => e.As <TEntity>()) .ResultsAsync); }
/// <summary> /// Gets the related. /// </summary> /// <typeparam name="TEntity2">The type of the entity2.</typeparam> /// <returns></returns> public virtual async Task <IEnumerable <TEntity2> > GetRelated <TEntity2, TRelationship>(Expression <Func <TEntity, bool> > query1, Expression <Func <TEntity2, bool> > query2, TRelationship relationship) where TEntity2 : Neo4jEntity, new() where TRelationship : Neo4jRelationship, new() { string name1 = query1.Parameters[0].Name; TEntity entity1 = (TEntity)Activator.CreateInstance(query1.Parameters[0].Type); string name2 = query2.Parameters[0].Name; TEntity2 entity2 = (TEntity2)Activator.CreateInstance(query2.Parameters[0].Type); Expression <Func <TEntity2, bool> > newQuery = PredicateRewriter.Rewrite(query2, "e"); return(await client.Cypher .Match("(" + name1 + ":" + entity1.Label + ")-[:" + relationship.Name + "]->(" + name2 + ":" + entity2.Label + ")") .Where(query1) .AndWhere(query2) .Return(e => e.As <TEntity2>()) .ResultsAsync); }