Hi ,
This is murali krishna i want one example on LINQ.
How can i create LINQ query and how to execute it. Please give me answer
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Murali KrishnaPosted Apr 1, 2013, 6:28 AM
Vishal GilbilePosted Apr 1, 2013, 6:18 AM
Well krishna linq can be used to query any database by using a standard query format. Let's assume we want to query an array, try to read all the values of an array and store it in listbox. Following is the code for the same. For firing any linq query you need to set up 3 things
1. Identiy your datasource
int[] arr={1,2,3,4,5,6,7,8,9,10}
2. Create your query
var query=from o in arr select o;
3. Execute your query.
foreach(var result in query)
{
listbox1.Items.Add(result.ToString());
}
Hope that solves your problem.
With Regards,
Vishal Gilbile