Category: LINQ
-
Internal of Deferred or Lazy Execution in LINQ
I have already posted about Deferred Execution here In this post we will see how internally Deferred or lazy execution is implemented. Deferred Execution executes the query only when Loop starts. What I mean here is that, we iterate through the query variable to get the result. Here the result variable does not contain the…
-
Read-Only Data in LINQ
By default CRUD operation can be performed on the retrieved data from LINQ query. We can modify the data fetched through LINQ query. IF we do not want to modify the data then we can increase the performance by making the data as READ ONLY. If we set ObjectTrackingEnabled as false for DataContext then…
-
Remote and Local execution of Query in LINQ
Remote Execution of Query 1. This query executes on the server. 2. Remote execution of query is default in LINQ. 3. In Remote execution advantage of Databases index can be taken. 4. Remote execution allows us to take the advantage of Database server engine. 5. Remote execution allows us to only select particular rows from…
-
Complied Queries in LINQ
There may be scenario where we need to execute a particular query many times and repeatedly. LINQ allows us to make this task very easy by enabling us to create a query and make it complied always. We call this type of query as complied query. Benefit of Compiled Query 1. Query does need…
-
Using Stored Procedure in LINQ
We have a strored procedure like below , It is a very simple SP returning grades of the student. This stored procedure name is GetStudentGrade USE [School] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetStudentGrades] @StudentID int AS SELECT EnrollmentID,…
-
Deferred Execution and Immediate Execution in LINQ
Deferred Execution executes the query only when Loop starts. What I mean here is that, we iterate through the query variable to get the result. Here the result variable does not contain the actual result. To get the result, we may iterate through the result (query) variable in loop as many time as…
-
Var versus IEnumerable in LINQ
We have seen normally Or Now question is where to use var or IEnumerable? Let us first have a look on both key words Var derives type from the right hand side. And its scope is in the method. And it is strongly typed. IEnumerable is interface which allows forward movement in the collection. Now…
-
Listing columns name with type of a table using LINQ
After my last post, I got a question asking how to list all the Column names of a given table using LINQ. Before going through this post, I recommend you to read Get All the Tables Name using LINQ Let us say, you have a table called dbo.Person and you need to find all the…
-
Get All the Tables Name using LINQ
We need to list all the table name of the DataContext. This is very simple through LINQ mapping. 1. Add the namespace 2. Get the model from type of datacontext DataClasses1DataContext is your datacontext class created by LINQ to SQL. 3. Use GetTables() method to list all the tables name using System; using System.Collections.Generic; using…