Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. deleting the miltiple records vb.net 3.5

deleting the miltiple records vb.net 3.5

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinq
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nilish
    wrote on last edited by
    #1

    i have a string "1,2,3,4,5,6" these are the ids , i want to delete the record which have these ids , in sql we use in predicate. can i use the in predicate in LINQ. I dopn't want to use the loops here.

    H 1 Reply Last reply
    0
    • N Nilish

      i have a string "1,2,3,4,5,6" these are the ids , i want to delete the record which have these ids , in sql we use in predicate. can i use the in predicate in LINQ. I dopn't want to use the loops here.

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      Without using loops this can be done:

      var IDs = @"1,2,3,4,5,6";
      var IDarray = IDs.Split(",");
      var toDelete = from T in db.Table
      where IDarray.Contains(T.ID)
      select T;
      db.Table.DeleteAllOnSubmit(toDelete);
      db.SubmitChanges();

      Unfortunately this results in six delete commands on the server, so it isn't as efficient as a single SQL delete command. Other people have been developing extensions to LINQ for deletes and updates which you could try out. See Aney's blog[^] or Zhao's blog[^] for more info.

      'Howard

      modified on Saturday, August 9, 2008 10:59 AM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups