public object ExecuteLinqCommand(EntitySession session, LinqCommand command) { object result; if (command.CommandType == LinqCommandType.Select && Cache != null && Cache.TryExecuteLinqQuery(session, command, out result)) { return(result); } result = Database.ExecuteLinqCommand(session, command); //If we are returning entities, cache them if (command.CommandType == LinqCommandType.Select) { var recs = result as IList <EntityRecord>; if (Cache != null && recs != null) { Cache.CacheRecords(recs); //adds to sparse cache } } else { // Update/Insert/Delete statemetns if (Cache != null && command.TargetEntity.CacheType != CacheType.None) { Cache.Invalidate(); } } return(result); }