private async Task <object> TryExecuteGetAsync(TranslationResult translationResult, Type entityType)
        {
            var entityKey = translationResult.TryGetEntityKeyForTable(this.TableDefinition);

            if (entityKey == null)
            {
                return(null);
            }

            Document resultDoc = null;

            // first trying to get entity from cache, but only if it's not a projection
            if (ReferenceEquals(this.TableEntityType, entityType))
            {
                resultDoc = this.Cache.GetSingleEntity(entityKey);
            }

            if (resultDoc != null)
            {
                this.Log("Get from cache: {0}", translationResult);
            }
            else
            {
                var config = new GetItemOperationConfig
                {
                    AttributesToGet = translationResult.AttributesToGet,
                    ConsistentRead  = this._consistentRead
                };
                translationResult.CustomizationHooks.ConfigureGetOperationCallback?.Invoke(config);

                // if the entity is not found in cache - then getting it from DynamoDb
                resultDoc = await this.TableDefinition.GetItemAsync
                            (
                    this.EntityKeyGetter.GetKeyDictionary(entityKey),
                    config
                            )
                            .ConfigureAwait(false); // This is important, as this method can be called synchronously from outside. Without this line it will hang in ASP.Net.

                // putting the entity to cache as well
                this.Cache.PutSingleLoadedEntity(entityKey, resultDoc);

                this.Log("Get from DynamoDb: {0}", translationResult);
            }

            // creating an enumerator for a single value or an empty enumerator
            return(this.CreateSingleDocReader(resultDoc, entityType, translationResult.ProjectionFunc));
        }
        private bool TryExecuteGet(TranslationResult translationResult, Type entityType, out object result)
        {
            result = null;

            var entityKey = translationResult.TryGetEntityKeyForTable(this.TableDefinition);

            if (entityKey == null)
            {
                return(false);
            }

            Document resultDoc = null;

            // first trying to get entity from cache, but only if it's not a projection
            if (ReferenceEquals(this.TableEntityType, entityType))
            {
                resultDoc = this.Cache.GetSingleEntity(entityKey);
            }

            if (resultDoc != null)
            {
                this.Log("Get from cache: " + translationResult);
            }
            else
            {
                // if the entity is not found in cache - then getting it from DynamoDb
                resultDoc = this.TableDefinition.GetItem
                            (
                    this.EntityKeyGetter.GetKeyDictionary(entityKey),
                    new GetItemOperationConfig
                {
                    AttributesToGet = translationResult.AttributesToGet,
                    ConsistentRead  = this._consistentRead
                }
                            );

                // putting the entity to cache as well
                this.Cache.PutSingleLoadedEntity(entityKey, resultDoc);

                this.Log("Get from DynamoDb: " + translationResult);
            }

            // creating an enumerator for a single value or an empty enumerator
            result = this.CreateSingleDocReader(resultDoc, entityType, translationResult.ProjectionFunc);

            return(true);
        }