Database Language Integrated Query or LINQ with Database is known as DLINQ.
Mainly used when we want to manipulate data from the database.
LINQ to SQL Statements
Data Context
Mapping of all entities and mainly tables entries to the database are provided by data context. Or we can say that, The association of the entities used in the project and for the database resides in the data context.
It is like an interface that the query is written by the user and executed into the database. The Data context is like a buffer that will manipulate the database entities
Example: A Simple Select
This is an example of a very simple LINQ to SQL statement:
public void SimpleQuery()
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var q =
from a in dc.GetTable<Order>()
select a;
dataGridView1.DataSource = q;
}
In the example, an instance of the data context is created and after then a query is formed to get all of the values in the table; once the query runs, the result is used as the data source of a DataGridView control and the results are displayed in the grid:
0 Comment(s)