I have a view and I am trying to query it. Every time I try to query it, it returns TotalRows: 2 which is the count but instead of returning the data in results it says “Enumeration yielded no results”
EDIT: Just to add, my old views work without any problem, this is a new view that I created yesterday.
I think the issue here is that your doing a _count Reduce. That by definition means you won’t be getting rows back, just the count. It’s kind of like doing COUNT(*) on a SQL query. If you remove the .Reduce call, you should get the actual rows back.
The difference is that you are calling .Reduce on the client side, I
think. That is simply an option controlling if it should use the Reduce
function in the view. So if you define the Reduce function in the view,
you can either choose to get the reduced result or not. But if you have no
function on the view, you can’t try to reduce it from the client side.
@btburnett3, so how do I resolve this? As I have tried both and the strange thing is my gifts view works properly as shown above using the same .Net Client code.
I have been trying to figure this out with no luck.
Sorry about this but I am having strange problems. Removing the Reduce worked fine however it gives me error when counting the totalcount of rows returned after filter as the value is null.
What I find strange is, if you look at Gifts view and it has reduce “_count” it uses the same function and it returns the data as well as the count.
The problem I am getting now without the “_count” on Badges view is, “System.NullReferenceException”, I am not sure why it gives value as null:
Thank you for helping resolve this issue, I have found the code where the problem is caused. It works fine with or without “_count” until it reaches this piece of code and then it causes the problem.
The problem occurs at → view = view.StartKey(filter.StartKey);
If I comment out this line of code it works fine until the System Null Reference error.
any idea why would startkey cause the “Enumeration yielded no results” error ?
Just as a guess, I’d think it’s the specific StartKey you’re passing. If the key you passed was greater than the largest key in the view index, then it would return no results. It could also be a problem with the format of the key you’re passing, making it seem like it’s greater. For example, the key should definitely be in an array format like “[‘some’,‘part’,‘here’]” based on your view definition from earlier.