Example #1
0
        public void Process(OptionsResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)
        {
            queryModelVisitor.VisitorParameters.ConstantToParameterMap.TryGetValue(resultOperator.SetOptions,
                                                                                   out NamedParameter parameterName);

            if (parameterName != null)
            {
                tree.AddAdditionalCriteria(
                    (q, p) => setOptions(q, (Action <IQueryableOptions>)p[parameterName.Name].Item1));
            }
            else
            {
                tree.AddAdditionalCriteria(
                    (q, p) => setOptions(q, (Action <IQueryableOptions>)resultOperator.SetOptions.Value));
            }

            void setOptions(IQuery query, Action <IQueryableOptions> set)
            {
                var options = new NhQueryableOptions();

                set(options);

                if (options.Timeout.HasValue)
                {
                    query.SetTimeout(options.Timeout.Value);
                }
                if (options.Cacheable.HasValue)
                {
                    query.SetCacheable(options.Cacheable.Value);
                }
                if (options.CacheMode.HasValue)
                {
                    query.SetCacheMode(options.CacheMode.Value);
                }
                if (options.CacheRegion != null)
                {
                    query.SetCacheRegion(options.CacheRegion);
                }
            }
        }
Example #2
0
 protected override IQueryProvider CreateWithOptions(NhQueryableOptions options)
 {
     return(new SampleQueryProvider(Session, Collection, options));
 }
Example #3
0
 protected SampleQueryProvider(ISessionImplementor session, object collection, NhQueryableOptions options) : base(session, collection, options)
 {
 }