Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:12:58+00:00 2026-06-01T20:12:58+00:00

I am trying to use Dapper support my data access for my server app.

  • 0

I am trying to use Dapper support my data access for my server app.

My server app has another application that drops records into my database at a rate of 400 per minute.

My app pulls them out in batches, processes them, and then deletes them from the database.

Since data continues to flow into the database while I am processing, I don’t have a good way to say delete from myTable where allProcessed = true.

However, I do know the PK value of the rows to delete. So I want to do a delete from myTable where Id in @listToDelete

Problem is that if my server goes down for even 6 mintues, then I have over 2100 rows to delete.

Since Dapper takes my @listToDelete and turns each one into a parameter, my call to delete fails. (Causing my data purging to get even further behind.)

What is the best way to deal with this in Dapper?

NOTES:
I have looked at Tabled Valued Parameters but from what I can see, they are not very performant. This piece of my architecture is the bottle neck of my system and I need to be very very fast.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:12:59+00:00Added an answer on June 1, 2026 at 8:12 pm

    One option is to create a temp table on the server and then use the bulk load facility to upload all the IDs into that table at once. Then use a join, EXISTS or IN clause to delete only the records that you uploaded into your temp table.

    Bulk loads are a well-optimized path in SQL Server and it should be very fast.

    For example:

    1. Execute the statement CREATE TABLE #RowsToDelete(ID INT PRIMARY KEY)
    2. Use a bulk load to insert keys into #RowsToDelete
    3. Execute DELETE FROM myTable where Id IN (SELECT ID FROM #RowsToDelete)
    4. Execute DROP TABLE #RowsToDelte (the table will also be automatically dropped if you close the session)

    (Assuming Dapper) code example:

    conn.Open();
    
    var columnName = "ID";
    
    conn.Execute(string.Format("CREATE TABLE #{0}s({0} INT PRIMARY KEY)", columnName));
    
    using (var bulkCopy = new SqlBulkCopy(conn))
    {
        bulkCopy.BatchSize = ids.Count;
        bulkCopy.DestinationTableName = string.Format("#{0}s", columnName);
    
        var table = new DataTable();                    
        table.Columns.Add(columnName, typeof (int));
        bulkCopy.ColumnMappings.Add(columnName, columnName);
    
        foreach (var id in ids)
        {
            table.Rows.Add(id);
        }
    
        bulkCopy.WriteToServer(table);
    }
    
    //or do other things with your table instead of deleting here
    conn.Execute(string.Format(@"DELETE FROM myTable where Id IN 
                                       (SELECT {0} FROM #{0}s", columnName));
    
    conn.Execute(string.Format("DROP TABLE #{0}s", columnName));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there som requisite that block Dapper use in a PortableLibraryProject? I'm trying to
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I am trying use a Java Uploader in a ROR app (for its ease
Trying to use records with the cursor and later index by table in the
I am trying use the new server side plug-in feature for TFS 2010. (I
I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
I am trying use the jQuery table sorter plugin for a table that is
I am trying use the onClick() function in an activity for an android app.
I'm trying to use Dapper simply to map my database tables to types in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.