private async Task <List <WorkTimeEntity> > GetWorkTimes(string userName, DateTime?startDate, DateTime?endDate) { var workTimesTable = await _tableHelper.GetTable(); var partitionKey = AccountUtils.GetPartitionIndexForName(userName).ToString(); var query = new TableQuery <WorkTimeEntity>() .AndWhereEquals(nameof(WorkTimeEntity.PartitionKey), partitionKey) .AndWhereEquals(nameof(WorkTimeEntity.UserName), userName); if (startDate != null) { query = query.AndWhereGreaterEqual(nameof(WorkTimeEntity.RowKey), startDate.Value.ToStorageSafeShortDateString()); } if (endDate != null) { query = query.AndWhereLessEqual(nameof(WorkTimeEntity.RowKey), endDate.Value.ToStorageSafeShortDateString()); } return(await workTimesTable.ExecuteQueryFull(query)); }