Enumeration yielded no results .Net Client

Hello Everyone,

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.

Can anyone help me with this problem.

Thank you.

can anyone suggest anything please ?


Can you post your code, please? That might help me understand what’s happening.


Hello @btburnett3,

Thank you for taking out time to read my question.

here is the code:

private IView<IViewRow> PrepareViewCall(DataViewFilter filter)
		if (filter == null)
			throw new ArgumentNullException("filter");

		if (String.IsNullOrWhiteSpace(filter.ViewName))
			throw new ApplicationException("ViewName is not specified");

		var designDocumentName = filter.DesignDocument;
		if (!String.IsNullOrWhiteSpace(filter.DesignDocumentPrefix))
			designDocumentName = string.Format("{0}-{1}", filter.DesignDocumentPrefix, filter.DesignDocument);

		IView<IViewRow> view =

		view = view.OnError(OnErrorMode.Stop);

		if (filter.Stale.HasValue)
			view = view.Stale(filter.Stale.Value);
		view = view.Descending(filter.Descending);

		if (filter.Group)
			view = view.Group(true);

		if (filter.GroupAt.HasValue)
			view = view.GroupAt(filter.GroupAt.Value);

		if (filter.StartKey != null)
			view = view.StartKey(filter.StartKey);
			if (filter.EndKey == null && filter.StartKey is string)
				view = view.EndKey(filter.StartKey + "\uefff");

		if (filter.EndKey != null)
			view = view.EndKey(filter.EndKey);

		if (filter.Key != null)

		if (filter.Keys != null)

		view = view.Skip(filter.StartPosition);
		view = view.Limit(filter.PageSize);
	  return view;

Hope that helps

@emran -

Can you also post the view definition? Also, use fiddler or Charles to post the response back from the server.


@jmorris sure.

Here is the view below with results

Here is the response using .Net Client, which shows the same total count from above but no data.

I hope the above helps.


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.


@btburnett3 Thank you for your reply.

I removed the count and now it gives me an error related to reduce and yet I do not get any data using .NET

Here is another view for Gifts which works perfectly fine and returns data using .Net Client even though it has got “_count”


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.

Any help will be appreciated.


@emran -

You’ll need to set Reduce(false) - or just remove the call to reduce altogether.


@jmorris -

I have removed call to Reduce(true), now I get this:

So no TotalRows and no Data in results ?


Can you show us the code that’s underneath the debugging info? Maybe there’s a clue there.



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:

@btburnett3 & @jmorris,

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 ?

1 Like


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.


1 Like

@btburnett3 perfect!

The problem was with the format.

The view required this format “[‘some’,‘part’,‘here’]” and I was sending “[‘some, ‘extra’, ‘part’’, ‘here’]”

Thanks a lot @btburnett3 & @jmorris <3