how to Update table column with random numbers using linq in asp.net. Please take a look at my code. same number is updated for all records in the list. what is going wrong in my code.
foreach(var item in list)
{
int rnd = 0;
//item.RandomNumber = GetRandomNumber();
Application app = new Application ();
app.Id = item.Id;
rnd = GetRandomNumber();
app.RandomNumber = rnd;
listapp.Add(app);
}
public int GetRandomNumber()
{
int Random = 0;
Random random = new Random();
Random = random.Next(1, 99999);
return Random;
}
It should update unique number for each list. but now column is updated with same number.