.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

LINQ to Dataset

Posted By:nishithraj       Posted Date: November 27, 2009    Points: 10    Category: LINQ    URL: http://www.dotnetspark.com  

LINQ to Dataset.

We can fill the Dataset even through the resultant of LINQ.

For example, If you required to find sales happened in Year 2002 from the collection salesorders you can go for LINQ. It requires only few lines of codes to achieve this.

The result can be filled to a dataset as shown in the code

var salesOrderInfo = from sales in SalesDataContext.SalesOrders
where salesOrder.OrderDate.Year == 2002
select salesOrder;
//Adding the resultant of LINQ to Dataset
In earlier versions the same logic can be achieved by loops and checking condition. That may affect the performance of the application.

So,it's always prefer using LINQ in such kind of scenarios.


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend