我正在使用VB.Net并有两个列表。我想只返回基于tempProduct2的id匹配的那些。我的linq是不正确的,有没有办法用linq到sql这样做?
public void updateprofile()
{
SqlConnection MySQL = new SqlConnection(ConfigurationManager.ConnectionStrings["BloodDonorRegistrationConnectionString"].ToString());
SqlCommand cmd = new SqlCommand("UPDATE Donor SET D_FirstName= @fn, D_LastName=@ln, D_Phone=@phn, D_City=@ct, D_Address=@add where D_Email='"+Session["UserID"]+"'", MySQL);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@fn", TextBoxFName.Text);
cmd.Parameters.AddWithValue("@ln", TextBoxLName.Text);
cmd.Parameters.AddWithValue("@phn", TextBoxCellNum.Text);
cmd.Parameters.AddWithValue("@ct", DropDownListCity.SelectedItem.Text);
cmd.Parameters.AddWithValue("@add", ButtonAddress.Text);
MySQL.Open();
cmd.ExecuteNonQuery();
MySQL.Close();
Response.Redirect("doDashboard.aspx");
}
答案 0 :(得分:1)
是的,您可以使用LINQ Any
方法执行此操作,如:
newList = (From p1 In tempProduct1
Where tempProduct2.Any(Function(x As Product) x.ID = p1.ID)
Select p1).ToList()