Note that there are some explanatory texts on larger screens.

plurals
  1. POPlease help me convert a Linq Query to a SQL Query... Desperate
    text
    copied!<p>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..</p> <p>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.</p> <p>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.</p> <p>Can anyone help? Thanks ALL!!!!!</p> <pre><code> 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(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload