Hey all,
Im pretty proficient in LINQ, but not in SQL. I understand cursors are horrible and shouldn't be used. I know SQL Syntax pretty well, but I am trying to figure out how to convert this query and update to SQL from Linq. I don't know how to go through the Foreach of SQL without using cursors and Im a bit lost on what to do next..
As you can see, I am going through an entire table of about 150,000 rows Linqpad just cannot handle the update, so I need this to be done in SQL.
Im iterating through each record in the first table, then finding a Guid in two other tables and pulling that data from those two tables and updating the original.
Can anyone help? Thanks ALL!!!!!
CS_Code.UtopiaDataContext db = new CS_Code.UtopiaDataContext();
var getFirst = (from xx in db.Utopia_Province_Data_Captured_Gens
select xx);
foreach (var item in getFirst)
{
var updateItem = (from xx in db.Utopia_Province_Infos
where xx.Province_ID == item.Province_ID
select xx).FirstOrDefault();
if (updateItem != null)
{
item.Owner_User_ID = updateItem.User_ID;
item.Last_Login_For_Province = updateItem.Last_Login_Province;
item.Date_Time_User_ID_Linked = updateItem.Date_Time_Added;
item.Added_By_User_ID = updateItem.Added_By_User_ID;
}
var updateItema = (from xx in db.Utopia_Province_Identifiers
where xx.Province_ID == item.Province_ID
select xx).FirstOrDefault();
if (updateItema != null)
{
item.Owner_Kingdom_ID = updateItema.Owner_Kingdom_ID;
item.Kingdom_ID = updateItema.Kingdom_ID;
item.Province_Name = updateItema.Province_Name;
item.Kingdom_Island = updateItema.Kingdom_Island;
item.Kingdom_Location = updateItema.Kingdom_Location;
}
}
db.SubmitChanges();