Dav Dav - 1 month ago 9
C# Question

How can I consider default data for IQueryable<className>

I have many IQueryable on my code, and sometimes I need to return data as nothing.
I don't want to return null as data, because I can't handle on client side

Also I test something like this, but didn't get result

IQueryable<className> obj=new IQueryable<className>();

Answer

I am used to use Enumerable.Empty<T>() when I need to return empty enumerables. In the same way you may return an empty IEnumerable as IQueryable;

Enumerable.Empty<className>().AsQueryable();