コード例 #1
0
        public void ItShouldThrowOnCacheableWithDirectWithOptionsCall()
        {
            Action act = () => LinqExtensionMethods.WithOptions(Enumerable.Empty <PersonEntity>().AsQueryable(), options => options.SetCacheable(true)).FirstOrDefault();

            act.Should()
            .Throw <NotSupportedException>()
            .WithMessage(
                "The query.Provider does not support setting options. Please implement IQueryProviderWithOptions.");
        }
        public static IQueryable <T> CacheableOk <T>(this IQueryable <T> query)
        {
            if (query.Provider.GetType() == typeof(NHibernate.Linq.DefaultQueryProvider))
            {
                query = LinqExtensionMethods.WithOptions(
                    query,
                    o =>
                {
                    o.SetCacheable(true);
                });
            }

            return(query);
        }