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