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 get next row value

how to get next row value

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqhelptutorial
2 Posts 2 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.
  • A Offline
    A Offline
    amalatsliit
    wrote on last edited by
    #1

    Hi, I just want to know how can i get next value from linq query..this is exactly what i want... in my table i have ID(int),venueID(int),VOM(bit) let say this will be on 1st month... ID : venueID : VOM 1 : 21 : 1 10 : 92 : 0 25 : 102 : 0 on next month i want to set table like this... ID : venueID : VOM 1 : 21 : 0 10 : 92 : 1 25 : 102 : 0 and on 3rd month should be ID : venueID : VOM 1 : 21 : 0 10 : 92 : 0 25 : 102 : 1 like wise VOM value should rotate every month.how can i achieve this from linq... need help...

    A 1 Reply Last reply
    0
    • A amalatsliit

      Hi, I just want to know how can i get next value from linq query..this is exactly what i want... in my table i have ID(int),venueID(int),VOM(bit) let say this will be on 1st month... ID : venueID : VOM 1 : 21 : 1 10 : 92 : 0 25 : 102 : 0 on next month i want to set table like this... ID : venueID : VOM 1 : 21 : 0 10 : 92 : 1 25 : 102 : 0 and on 3rd month should be ID : venueID : VOM 1 : 21 : 0 10 : 92 : 0 25 : 102 : 1 like wise VOM value should rotate every month.how can i achieve this from linq... need help...

      A Offline
      A Offline
      Andreas X
      wrote on last edited by
      #2

      I think this is a perfect case for the modulus operator.

      DataContext db = new DataContext();
      for(int month = 1; month <= 12; month++)
      {
      DataEntry de = new DataEntry();
      de.ID = 1;
      de.venuelID = 21;
      de.VOM = (month % 1) == 0;
      db.DataTable.InsertOnSubmit(de);

      DataEntry de = new DataEntry();
      de.ID = 10;
      de.venuelID = 92;
      de.VOM = (month % 2) == 0;
      db.DataTable.InsertOnSubmit(de);
      
      
      DataEntry de = new DataEntry();
      de.ID = 21;
      de.venuelID = 102;
      de.VOM = (month % 3) == 0;
      db.DataTable.InsertOnSubmit(de);
      

      }
      db.SubmitChanges();

      Is this what you want or have i missunderstod?

      Andreas Johansson
      IT Professional at Office IT Partner i Norrbotten Sweden
      What we don't know. We learn.
      What you don't know. We teach

      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