Sunday 24 July 2016

LINQ to SQL basic example

Posted by : Manav Pandya

Here you can see that we have used some data as follow :

[ 1 ] using System. Linq;


This namespace defines that we are using LINQ query mechanism , and it will provide intellisense to use necessary attributes

[ 2 ] Data Source


It defines that we are using "StudentDataContext" , it means we are connected to database by this object .

[ 3 ]  Executing Query 


As you can see query is there , so that its time to execute LINQ to SQL query as above example , it will print all result that returned by "stdNames" variable


Normally it does 

  • Create connection to database
  • It submits and retrives object to database
  • Convert object to SQL queries and vice versa