internal static IQueryable <TResult> IgnoreModificationSelect <TResult>(this IAqlModifiable <TResult> source)
 {
     return(source.Provider.CreateQuery <TResult>(
                Expression.Call(
                    FindExtention("IgnoreModificationSelect", typeof(TResult)),
                    source.Expression)));
 }
 public static IAqlModifiable <TResult> In <TResult>(this IAqlModifiable source)
 {
     return(source.Provider.CreateQuery <TResult>(
                Expression.Call(
                    FindExtention("In", typeof(TResult)),
                    source.Expression
                    )) as IAqlModifiable <TResult>);
 }
 public static IAqlModifiable <TResult> In <TResult>(this IAqlModifiable source)
 {
     return(source.Provider.CreateQuery <TResult>(
                Expression.Call(
                    FindCachedMethod("In", typeof(TResult)),
                    source.Expression
                    )).AsAqlQueryable().KeepState(source as IQueryableState) as IAqlModifiable <TResult>);
 }
 internal static IAqlModifiable <TResult> ReturnResult <TResult>(this IAqlModifiable <TResult> source, bool returnNewResult)
 {
     return(source.Provider.CreateQuery <TResult>(
                Expression.Call(
                    FindCachedMethod("ReturnResult", typeof(TResult)),
                    source.Expression,
                    Expression.Constant(returnNewResult)
                    )).AsAqlQueryable().KeepState(source as IQueryableState) as IAqlModifiable <TResult>);
 }
        public static IQueryable <TResult> Select <TSource, TResult>(this IAqlModifiable <TSource> source, Expression <Func <TSource, TSource, TResult> > selector)
        {
            var newSelector = ExpressionParameterRewriter.RewriteParameters(selector, "NEW", "OLD");

            return(source.Provider.CreateQuery <TResult>(
                       Expression.Call(
                           FindExtention("SelectModification", typeof(TSource), typeof(TResult)),
                           source.Expression,
                           Expression.Quote(newSelector))));
        }
        private static bool IsNewResult <T>(IAqlModifiable <T> source)
        {
            switch (source.AsAqlQueryable().StateValues["CrudFunction"])
            {
            case "insert":
            case "update":
            case "replace":
            case "upsert":
                return(true);

            case "remove":
                return(false);

            default:
                return(false);
            }
        }
 public static void Execute <T>(this IAqlModifiable <T> source)
 {
     // AsCursor is needed for executing query by ArangoQueryable methods instead of ArangoQueryExecuter
     source.IgnoreModificationSelect().AsCursor().ToList();
 }
 public static void Execute <T>(this IAqlModifiable <T> source)
 {
     source.AsAqlQueryable <T>().ToList();
 }
        public static List <T> ToList <T>(this IAqlModifiable <T> source, bool returnNewResult)
        {
            var newSource = ReturnResult <T>(source, returnNewResult);

            return(newSource.AsAqlQueryable <T>().ToList());
        }
 public static async Task ForEachAsync <T>(this IAqlModifiable <T> source, Action <T> action, bool returnNewResult)
 {
     var newSource = ReturnResult <T>(source, returnNewResult);
     await newSource.AsAqlQueryable <T>().ForEachAsync(x => action(x)).ConfigureAwait(false);
 }
 public static List <T> ToList <T>(this IAqlModifiable <T> source)
 {
     return(ToList(source, IsNewResult(source)));
 }
 public static async Task ForEachAsync <T>(this IAqlModifiable <T> source, Action <T> action)
 {
     await ForEachAsync <T>(source, action, IsNewResult(source)).ConfigureAwait(false);
 }
        public static async Task <List <T> > ToListAsync <T>(this IAqlModifiable <T> source, bool returnNewResult)
        {
            var newSource = ReturnResult <T>(source, returnNewResult);

            return(await source.AsAqlQueryable <T>().ToListAsync().ConfigureAwait(false));
        }
 public static async Task <List <T> > ToListAsync <T>(this IAqlModifiable <T> source)
 {
     return(await ToListAsync <T>(source, IsNewResult(source)));
 }
        public static void ForEach <T>(this IAqlModifiable <T> source, Action <T> action, bool returnNewResult)
        {
            var newSource = ReturnResult <T>(source, returnNewResult);

            newSource.AsAqlQueryable <T>().ForEach(x => action(x));
        }
        /*crud extentions*/

        public static void ForEach <T>(this IAqlModifiable <T> source, Action <T> action)
        {
            ForEach <T>(source, x => action(x), IsNewResult(source));
        }