New Posts New Posts RSS Feed: Query Inversion not working in EntityServerSaveInterceptor ?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Query Inversion not working in EntityServerSaveInterceptor ?

 Post Reply Post Reply
Author
kdev View Drop Down
Groupie
Groupie
Avatar

Joined: 03-Jan-2013
Posts: 83
Post Options Post Options   Quote kdev Quote  Post ReplyReply Direct Link To This Post Topic: Query Inversion not working in EntityServerSaveInterceptor ?
    Posted: 05-Jul-2013 at 8:33am
Hi,

I have a strange behaviour with, I think the Query inversion, in my EntityServerInterceptor in Fake mode.

Exemple : In a for loop, I try to always load the same entity.

Case 1 : Mode normal (QueryStrategy = Normal)


protected override void ExecuteSave()
{
    ...
    var CounterName = "test";
    for(int bcl = 1 ; bcl < 4; bcl++)
    {
        var compteur = new EntityQuery<Compteur>().With(EntityManager).FirstOrNullEntity(p => p.Code == CounterName);
       
        if (compteur.EntityFacts.IsNullEntity)
        {
            compteur = Compteur.Create(CounterName);
            EntityManager.AddEntity(compteur);
        }
        compteur.Valeur = compteur.Valeur + 1;
    }


=> 1st iteration an entity is created, others iteration get the newly entity.


case 2 : Mode Fake (QueryStrategy = Normal)


{ Same code }


=> Each iteration create a new Entity, the EntityManager never find the 1st entity.

case 3 : Mode Fake + QueryStrategy.DateSourceThenCache


protected override void ExecuteSave()
{
    ...
    var CounterName = "test";
    for(int bcl = 1 ; bcl < 4; bcl++)
    {
        var compteur = new EntityQuery<Compteur>().With(EntityManager).With(queryStrategy.DataSourceThenCache).FirstOrNullEntity(p => p.Code == CounterName);
       
        if (compteur.EntityFacts.IsNullEntity)
        {
            compteur = Compteur.Create(CounterName);
            EntityManager.AddEntity(compteur);
        }
        compteur.Valeur = compteur.Valeur + 1;
    }
=> Give the same result as case 1.


    
Case 4 : Use of an EntityKeyQuery in Fake store (QueryStrategy.Normal)


protected override void ExecuteSave()
{
     ...
    var CounterName = "test";
    for(int bcl = 1 ; bcl < 4; bcl++)
    {
        var queryKey = new EntityKey(typeof(Compteur), CounterName);
        var query = new EntityKeyQuery(queryKey);
        var compteur = EntityManager.ExecuteQuery(query).Cast<Compteur>().FirstOrDefault();
       
        if (compteur == null || compteur.EntityFacts.IsNullEntity)
        {
            compteur = Compteur.Create(CounterName);
            EntityManager.AddEntity(compteur);
        }
        compteur.Valeur = compteur.Valeur + 1;
    }


=> Give the same result as case 1.

Regards,
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jul-2013 at 6:02pm
Hi kdev,

I was able to reproduce the problem and am bringing this up to our senior engineer.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down