Part 17 AsEnumerable and AsQueryable in LINQ

kudvenkat
kudvenkat
115.3 هزار بار بازدید - 10 سال پیش - Text version of the video
Text version of the video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
@aarvikitchen5572

Slides
http://csharp-video-tutorials.blogspo...

LINQ Tutorial - All Text Articles & Slides
http://csharp-video-tutorials.blogspo...

LINQ Tutorial Playlist
LINQ Tutorial

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
https://www.youtube.com/user/kudvenka...

In this video we will discuss the use of AsEnumerable and AsQueryable operators in LINQ. Both of these operators belong to Conversion Operators category.

AsQueryable operator : There are 2 overloaded versions of this method.
One overloaded version converts System.Collections.IEnumerable to System.Linq.IQueryable
The other overloaded version converts a generic System.Collections.Generic.IEnumerable[T] to a generic System.Linq.IQueryable[T]

The main use of AsQueryable operator is unit testing to mock a queryable data source using an in-memory data source. We will discuss this operator in detail with examples in unit testing video series.

AsEnumerable operator breaks the query into 2 parts
1. The "inside part" that is the query before AsEnumerable operator is executed as Linq-to-SQL
2. The "ouside part" that is the query after AsEnumerable operator is executed as Linq-to-Objects

So in this example the following SQL Query is executed against SQL Server, all the data is brought into the console application and then the WHERE, ORDERBY & TOP operators are applied on the client-side
SELECT [t0].[ID], [t0].[Name], [t0].[Gender], [t0].[Salary]
FROM [dbo].[Employees] AS [t0]

So in short, use AsEnumerable operator to move query processing to the client side.
10 سال پیش در تاریخ 1393/05/02 منتشر شده است.
115,383 بـار بازدید شده
... بیشتر