Print Page | Close Window

Query Inversion not working in EntityServerSaveInterceptor ?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4212
Printed Date: 07-Sep-2025 at 8:51am


Topic: Query Inversion not working in EntityServerSaveInterceptor ?
Posted By: kdev
Subject: Query Inversion not working in EntityServerSaveInterceptor ?
Date 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,



Replies:
Posted By: sbelini
Date 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.



Print Page | Close Window