O'Reilly logo

Applied ASP.NET 4 in Context by Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using LINQ Queries As Data Sources

The LinqDataSource control supports only the basic LINQ clauses, such as select, where, and orderby. As I mentioned earlier, the LinqDataSource control will operate on any strongly typed IEnumerable sequence. One consequence of this is the ability to use the results from LINQ queries defined in code as the source for the data. Listing 18-13 shows a LINQ query defined in the Default.aspx.cs code-behind file.

Listing 18-13. Defining a LINQ query

using System; using System.Collections.Generic; using System.Linq; namespace WebApp {     public partial class Default : System.Web.UI.Page {         public IEnumerable<LinqWrapper> AthleteNames                 = new TrainingDataEntities().Events                      ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required