Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. How to read List Items ?

How to read List Items ?

Scheduled Pinned Locked Moved LINQ
csharpasp-netlinqhelptutorial
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varshavmane
    wrote on last edited by
    #1

    Hello All, I am using ASP.NET 3.5 (C#) with LINQ. I am getting 8 elements in the List but I dont know how to read each element.

    List yp = _datacontext.New_Patients.Where(a =>;a.StageTimeLineType.StageID.Equals(0)).OrderBy(a => a.Year).ThenBy(a => a.PeriodIdentifier).Select(a => new YearPeriods(a.Year, a.PeriodIdentifier)).ToList();

    here yp returns 8 rows ... Data will be something like this: PeriodIdentifier | Year 13 | 2007 14 | 2007 15 | 2007 16 | 2007 13 | 2008 14 | 2008 15 | 2008 16 | 2008 I have take every element and generate columns runtime for GridView. Column Names will be something like Q1 07, Q2 07, Q3 07, Q4 07, Q1 08, Q2 08, Q3 08 and Q4 08 Please help me ... Thanks in advance ....

    M 1 Reply Last reply
    0
    • V varshavmane

      Hello All, I am using ASP.NET 3.5 (C#) with LINQ. I am getting 8 elements in the List but I dont know how to read each element.

      List yp = _datacontext.New_Patients.Where(a =>;a.StageTimeLineType.StageID.Equals(0)).OrderBy(a => a.Year).ThenBy(a => a.PeriodIdentifier).Select(a => new YearPeriods(a.Year, a.PeriodIdentifier)).ToList();

      here yp returns 8 rows ... Data will be something like this: PeriodIdentifier | Year 13 | 2007 14 | 2007 15 | 2007 16 | 2007 13 | 2008 14 | 2008 15 | 2008 16 | 2008 I have take every element and generate columns runtime for GridView. Column Names will be something like Q1 07, Q2 07, Q3 07, Q4 07, Q1 08, Q2 08, Q3 08 and Q4 08 Please help me ... Thanks in advance ....

      M Offline
      M Offline
      Mohammad Dayyan
      wrote on last edited by
      #2

      I'm new on LINQ, but maybe you should use something like this :

      List yp = from q in _datacontext
      where ( your condition)
      orderby q.Year ascending
      select new
      {
      q.Year,
      q.PeriodIdentifier
      };

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups