IEnumerable vs IQueryable , which one to use in SOA and non-SOA?
-
Friday, March 02, 2012 8:47 PM
I am writing a Service Layer which has classes with methods returning lists of business objects, what should those methods' return types be ? IEnumerable or IQueryable and Why ?
Thanks
Fahad
All Replies
-
Friday, March 02, 2012 10:13 PM
On 3/2/2012 3:47 PM, Fahad349 wrote:> I am writing a Service Layer which has classes with methods returning> lists of business objects, what should those methods' return types be ?> IEnumerable or IQueryable and Why ?>It should return a List<T> which can be queried and enumerated.- Marked As Answer by Allen Li - AI3Microsoft Contingent Staff, Moderator Friday, March 09, 2012 1:48 AM
-
Monday, March 05, 2012 6:44 AMModerator
Hi Fahad349,
Welcome to MSDN Forum.
The primary difference is that the extension methods defined for IQueryable<T> take Expression objects instead of Func objects, meaning the delegate it receives is an expression tree instead of a method to invoke. IEnumerable<T> is great for working with in-memory collections, but IQueryable<T> allows for a remote data source, like a database or web service.
Here's an article I think can help you.
http://odetocode.com/Articles/738.aspx
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Allen Li - AI3Microsoft Contingent Staff, Moderator Friday, March 09, 2012 1:48 AM

