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. Get next record !!!!!

Get next record !!!!!

Scheduled Pinned Locked Moved LINQ
tutorialquestion
4 Posts 4 Posters 0 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.
  • Z Offline
    Z Offline
    zeeShan anSari
    wrote on last edited by
    #1

    hi all, let's suppose var q = context.Student.where(s=>s.id==1).?????????? how to i get next record where s.id==1 ? :((

    P R J 3 Replies Last reply
    0
    • Z zeeShan anSari

      hi all, let's suppose var q = context.Student.where(s=>s.id==1).?????????? how to i get next record where s.id==1 ? :((

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      It's simple to iterate over the query. As Linq uses deferred execution, you could do the following:

      foreach (Student item in q)
      {
      Console.WriteLine(item.Name);
      }

      Or, you could convert the output to a list:

      List<Student> students = q.ToList();

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      1 Reply Last reply
      0
      • Z zeeShan anSari

        hi all, let's suppose var q = context.Student.where(s=>s.id==1).?????????? how to i get next record where s.id==1 ? :((

        R Offline
        R Offline
        Ryomin
        wrote on last edited by
        #3

        Perhaps this will work for you.

        var studentList = from s in context.Students
        where s.id.Equals(1)
        select s;

        foreach(Student student in studentList)
        {
        Console.Write(student.id);
        }

        Cheers Disgyza Programmer Analyst

        1 Reply Last reply
        0
        • Z zeeShan anSari

          hi all, let's suppose var q = context.Student.where(s=>s.id==1).?????????? how to i get next record where s.id==1 ? :((

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          var q = context.Student.where(s=>s.id==1).FirstOrDefault();

          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