What is the best way to remove multiple records in one go with LINQ?
I agree with Khurram, it's much more efficient to do this with a simple stored procedure with LINQ (provided you have sufficient permissions in SQL to do this). I'll augment this with an example.
The stored procedure:
CREATE PROCEDURE [dbo].[RemovePermissionsFromRole]
(
@ROLE_ID int
)
AS
BEGIN
SET NOCOUNT ON;
DELETE FROM [RolePermissions] WHERE [RoleID] = @ROLE_ID;
END
Drag the stored procedure from the database explorer onto the methods pane in your DBML file. Save the file. And in code:
if (Request.QueryString["RoleID"] != null) {
int roleID = Convert.ToInt32(Request.QueryString["RoleID"]);
SETSDataContext context = new SETSDataContext();
context.RemovePermissionsFromRole(roleID);
}