How to: Shape the return type of a LINQ statement

Thread is closed for posting
1 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 24 Jan 2013 Link to this post

    Requirements

    OpenAccess version

     Q3 2012 SP1

    .NET version

     3.5, 4.0, 4.5

    Visual Studio version

     2008, 2010, 2012

    programming language

     C# and VB

    RadControls version

    ASP.NET Ajax Q3 2012 SP2   


    PROJECT DESCRIPTION                                    
    In order to pass the result from a LINQ statement to a method or assign it to a property, you may need to modify it so that it corresponds to certain logic.

    This project demonstrates the two most common approaches applied in such cases:
    • Shaping the result to an anonymous type
    • Shaping the result to a predefined result set

    When you use an anonymous type the definition of the result shape is performed in the LINQ statement itself, while with the predefined result set you need to strongly-type the properties of the result in a class.

    The anonymous type approach can be very useful in cases when you need to populate a lot of grids with different content, whereas the predefined result set is appropriate when you populate controls with the same content.

    The project is created using Telerik OpenAccess ORM Q3 2012 SP1 (version 2012.3.1209).

    Prerequisites

    The Northwind database

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.