3

I'm using Breeze.Sharp within a thick client application with WebApi at the server side. There is an issue I am noticing when I make multiple calls of ExecuteQuery on EntityManager object.

If the tasks returned by ExecuteQuery calls are not completed in the order they were created with, then the EntityManager will fail to change the state of any modified entities. Modified entities will always stay in Unchanged state, thereby sending blank response in the SaveChanges call.

public Task<IEnumerable<SomeType>> GetSomeTypeAsync(string type)
    {
        EntityQuery<SomeType> query = new EntityQuery<SomeType>()
            .Expand("Nav1,Nav2").Where(s => s.Type = type);

        return entityManager.ExecuteQuery(query);
    }

The code above is pretty straight forward, but if I call this method in a loop with some calls slower than the others I get the issue as described.

Looking into the source seems like EntityManager is not thread safe. There is an internal boolean property IsLoadingEntity on the EntityManager object which stays set to True as it goes through these multiple ExecuteQuery calls and even when all tasks get completed this property doesn't get set back to false. And this results in SaveChanges doing nothing.

Does this sound familiar to anyone? Have we got any fixes or am I doing something completely wrong?

sethidev
  • 111
  • 5
  • 2
    We're experiencing the same issue. Did you manage to find a solution? – mrBob Aug 16 '16 at 13:24
  • We just had to make ExecuteQuery calls sequentially rather than in parallel. It's not ideal but with EntityManager not being thread safe this was the only workaround. I wonder if it's the same issue with BreezeJs as well, will have to try that out. – sethidev Aug 25 '16 at 10:29
  • 1
    We ended up doing the same thing. It's less than ideal, but it resolved our issue – mrBob Aug 26 '16 at 12:03

0 Answers0