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); }
internal static IAqlModifiable <TSource> InternalUpsert <TSource, TOld>(this IQueryable <TSource> source, Expression <Func <TSource, object> > searchExpression, Expression <Func <TSource, object> > insertExpression, Expression <Func <TSource, TOld, object> > updateExpression, Type updateType) { source.AsAqlQueryable().StateValues["CrudFunction"] = "upsert"; var newUpdateExp = PredicateRewriter.Rewrite(updateExpression, "OLD"); return(source.Provider.CreateQuery <TSource>( Expression.Call( FindCachedMethod("InternalUpsert", typeof(TSource), typeof(TOld)), source.Expression, Expression.Quote(searchExpression), Expression.Quote(insertExpression), Expression.Quote(newUpdateExp), Expression.Constant(updateType) )).AsAqlQueryable().KeepState(source as IQueryableState) as IAqlModifiable <TSource>); }
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); }