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

  • Home
  • SEARCH
  • 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 1074287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:06:15+00:00 2026-05-16T21:06:15+00:00

Table entity column is unique, and I’m trying to add items. Items amount is

  • 0

Table entity column is unique, and I’m trying to add items. Items amount is fairly big, so i’m trying to avoid connecting to a database many times. What is the best way to ignore duplicates?

Example: code

Edit: Problem was word1 was of type nchar(50), so after changing it to nvarchar(50) everything worked.

  • 1 1 Answer
  • 1 View
  • 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-05-16T21:06:16+00:00Added an answer on May 16, 2026 at 9:06 pm

    It sounds like you want to avoid inserting those words that are already in the table.

    HashSet<string> words; 
    
    List<string> newWords = words.Except(lh.words.Select(w=>w.word1))
                                 .ToList();
    
    lh.words.InsertAllOnSubmit(newWords.Select(x=> new word { word1 = x}));
    

    Your code, as you have it today, will send all the INSERTS one after each other, in the same batch. It’ll create a single connection for them all with the one SubmitChanges() that you have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have rows in an Oracle database table which should be unique for a
suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
How would one structure a table for an entity that can have a one
I have an entity that maps to an external oracle table which is one
Academia has it that table names should be the singular of the entity that
i've got this tables in my database. alt text http://img166.imageshack.us/img166/3133/testdbschemafy5.png With Entity Framework i
Is it possible to make a foreign key unique within a table? Suppose I
I have a domain object and annotated as follows @Entity @Table(name = REQUEST) public
I have a simple domain class Licensee: @Entity @Table(name = LICENSEE) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
I have the following entity (getters and setters ommited)... @Entity @Table(name = TBL_PROJECT_RUN) public

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.