cache query using entityframework-plus extension


I want to use entityframework-plus extension to cache some of my queries, but it does not have any option to select specific items and cache them, as I read its document, it caches all of the columns like this :

ctx.Countries.Where(x => x.IsActive).FromCache()

but I have something like this:

db.tbl_Brand_To_Product.Where(x => x.tbl_BrandID == id).Select(x => x.tbl_ProductID)

I want to select just tbl_ProductID IDs not select *

anybody works with this extension? is there any option to do this ? or even is there any other extension which can cache my query ?

Accepted Answer

This is the response of its developer:

This is the response of its developer

after some search, I found HttpContext.Cache method to cache my results.

Popular Answer

FromCache() method can only be used on IQueryable<TEntity> objects. As your .Select(x => x.tbl_ProductID) instruction returns an IQueryable<int> (or whatever type tbl_ProductID is) you won't be able to use the extension method.

You can download the whole source code from GitHub and see the class file CacheExtensions.cs

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why