How to Load Related Entities after retrieving item from Memcache

75 views Asked by At

I'm storing an object into Memcached using Enyim.

However, when pulling this object out of Memcached the related entities are null. Using System.Runtime.Caching the entities load perfectly fine. Any help or hints to store these related entities would be really appreciated. Thank you.

[Serializable]
public class Inventory
{
    public Inventory() {  }

    public int InventoryID { get; set; }

    //Not Null
    public int ProductID { get; set; }

    //Null with Enyim
    public virtual Product Product { get; set; }

    //Null with Enyim
    public virtual ICollection<WarehouseInventory> WareHouseInventories { get; set; }

....
}
1

There are 1 answers

0
Mario On

You have to disable dbContext.Configuration.ProxyCreationEnabled, and make sure all aggregated objects are loaded when Inventory object is materialized. (Use 'Include' extension method on Invetory object from System.Data.Entity namespace)