Giter Site home page Giter Site logo

Comments (3)

Mimetis avatar Mimetis commented on June 11, 2024

OnRowsChangesApplied is called for every table and depends on multiple factors:

  • If you have multiple batch files to be applied, for one table, it will be called for each batch
  • If you have set a batch a max lines count, it will be called also for each max lines count applied
  • And finally it will be called for each state of your table Modified and Deleted

If your scenario, I guess it's called for the state Modified and Deleted

One thing you can do, is to check the values of the argument, something like that:

agent.LocalOrchestrator.OnRowsChangesApplied(args =>
{
    // check state
    if (args.State == SyncRowState.Modified)
        Console.WriteLine("State: Insert or Edit rows");
    else if (args.State == SyncRowState.Deleted)
        Console.WriteLine("State: Delete rows");
    else
        Console.WriteLine($"State: Retry or Fail ?: {args.State}");

    // Check if we have some rows applied
    if (args.SyncRows == null || args.SyncRows.Count <= 0)
        Console.WriteLine($"No rows applied for this state");

});

If you don't have bulk mode enabled (Only SqlSyncProvider supports it), OnRowsChangesApplied is called for every rows, twice (each state)

If you need less granular event, you can use

  • OnBatchChangesApplied that will only be raised for each batch files applied.
  • OnTableChangesApplied that will occurs at the end, after all batches are applied and all conflicts resolved.

That being said, you still have two events raised, for each state (Deleted / Modified)

Obviously the lesser granular level would be OnDatabaseChangesApplied, I guess.

Make sense ?

from dotmim.sync.

Mimetis avatar Mimetis commented on June 11, 2024

That being said, I just made some tests and the interceptor should not be called twice for each rows...
Can you provide me a sample to be able to reproduce your issue ?

from dotmim.sync.

Mimetis avatar Mimetis commented on June 11, 2024

Another thing to mention, if you are using bulk insert with SqlSyncProvider, you could have a particular where the bulk method is called and tries to insert/update a bunch of rows, but it's failing for some reasons.
OnRowsChangesApplied is called with all the rows failing and the explicit error (you can retrieve this error from the argument)

Then, DMS tries to applies all these rows, one by one. In some cases, applying rows one by row can resolve the issue.
OnRowsChangesApplied is called a second time in this particular case.

Can you check if it's the case for you ?

from dotmim.sync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.