Prevent LINQ from trying to InsertOnSubmit duplicate records??? Just cant get it!!!!! RRS feed

  • Question

  • Ok here is the situation:

    I have a table in my DB called ytVideos, in this table are 3 columns, id (pri Key with auto inc) ytUserName, and ytVidId (this is set to unique key as well)

    is im getting XML data 50 entries at a time I am adding these to my
    linq Insertonsubmit(ytvideo) looping through all the entries. Then ill
    move on to the next page of entries again another 50. After i have
    looped through all the entries and pages i try to run
    dc.submitchanges() I get a exeption thrown saying that I can not insert
    duplicate records in the ytVidId column. What is happening is the
    datasupplier might give me id xyz123 as page 1 entry 50 and then on
    page 2 entry 52 (if you will) xyz123 again. When i try and submit it
    fails, I got it to work if i submit after every record but im trying to
    save resources on DB Calls. Is there a way to check the "pending" linq
    records for duplicates and remove the row before i fire submitchanges()

    Sunday, September 21, 2008 6:07 PM