posts - 236, comments - 436, trackbacks - 56

My Links

News

Awarded Microsoft MVP C#.NET - 2007, 2008 and 2009


I am born in Bangladesh and currently live in Melbourne, Australia. I am a Microsoft Certified Application Developer MCAD Chartered Member (C# .Net)and born in Bangladesh.
I am founder and Chief Executive Officer of
Simplexhub, a highly experienced software development company based in Melbourne Australia and Dhaka, Bangladesh. Co-founder and core developer of Pageflakes www.pageflakes.com.
Simplexhub, is on its mission to build a smart virtual community in Bangladesh and recently launched beta realestatebazaar.com.bd an ASP.NET MVC application written in C#.NET.


Some of My Articles
Flexible and Plugin based .Net Application..
Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker'
Write your own Code Generator or Template Engine in .NET

Archives

Free Programming Language Training

LINQ Tips: Querying disposable objects in an using block

Be careful while querying the disposable object inside an using block, you may find that the yielded objects are all disposed before you have used them. To get over this issue use the ToList() method. You can exit the using block, and yield the results out.

Example:

IEnumerable<Student> results;
using (var db = new StudentDataContext())
{
  results = db.Students.Where(...).ToList();
}
foreach (var student in results)
{
  SomeMethod(student);
  yield return student;
}

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Tuesday, February 05, 2008 1:33 PM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: