convert a sequence to a generic list using ToList()method
LINQ queries have a unique feature. They are run only when we attempt to consume the result. For example, when a forloop is used, the query is run only when we iterate through the result. This is referred to as deferred evaluation. Given below is a LINQ to SQL query which runs against a database.
However, there are some methods which force immediate evaluation of a LINQ query. ToList() is one such method. When used, LINQ evaluates the query immediately. The ToList() method converts a LINQ var into a List<T> object. Then we can bind the list to any data bound controls like DataGrid or Listbox control etc.
The above query returns anonymous type and ToList() method converts anonymous type into a list.
However, there are some methods which force immediate evaluation of a LINQ query. ToList() is one such method. When used, LINQ evaluates the query immediately. The ToList() method converts a LINQ var into a List<T> object. Then we can bind the list to any data bound controls like DataGrid or Listbox control etc.
Example1: SalesDBDataContext dataContext = new SalesDBDataContext(); var custQuery = from c in dataContext.Customers select c; List<Customer> qList = custQuery.ToList(); Example2: SalesDBDataContext dataContext = new SalesDBDataContext(); var custQuery = from c in dataContext.Customers select new {c.CustomerId, c.Name }; var qList = custQuery.ToList();
The above query returns anonymous type and ToList() method converts anonymous type into a list.
Azure Q & A
Azure Platform
Grid-View
GridView CommandField example
Details-View
GridView and DetailsView Master/Detail page using SqlDataSource control
POCO
POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
Entity Framework
Query entity data model using linq to entities
Array List
Difference between arraylist and list collection
Web Services
How to create a Web service using Visual Studio.net
Form-View
FormView DataBound Event
Object Oriented Programming
Calling base class constructor in C#
Project Ideas
Project ideas for students
AccountingSoftware
Accounting Software
MVC
Creating an ASP.Net MVC 3 application
.Net
Using assemblies in .net applications
ASP .Net
How to implement form validation using ASP.Net 2.0 Validation Controls
VB .Net
Constructors in Visual Basic.Net