public async Task <IEnumerable <TEntity> > FindAsync(IQueryOptions <TEntity> queryOptions)
        {
            var options = queryOptions.GetOptions();

            var query = new Query(_kind)
            {
                //TODO: Handle multiple property sorts
                Order = { options.PropertyOrders },
            };

            //if (!string.IsNullOrEmpty(options.Skip))
            //    query.StartCursor = ByteString.FromBase64(options.Skip);

            if (options.Limit != null)
            {
                query.Limit = options.Limit;
            }

            var results = await _database.RunQueryAsync(query);

            return(results.Entities.Select(BuildDalEntity));
        }
        public long Count(IQueryOptions <TEntity> queryOptions)
        {
            var query = new Query(_kind)
            {
                Projection = { "__key__" }
            };

            if (queryOptions != null)
            {
                var options = queryOptions.GetOptions();

                query = new Query(_kind)
                {
                    Filter     = queryOptions.GetFilter(),
                    Projection = { "__key__" },
                    Order      = { options.PropertyOrders },
                    Limit      = options.Limit
                };
            }

            var results = _database.RunQuery(query);

            return(results.Entities.Count);
        }