Print Page | Close Window

Problem with property interceptors and queries

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4007
Printed Date: 07-Sep-2025 at 7:18am


Topic: Problem with property interceptors and queries
Posted By: MaksimK
Subject: Problem with property interceptors and queries
Date Posted: 25-Feb-2013 at 11:58pm
I have the following problem.

I am added the following property interceptor, that works fine

    [IbCore.AfterGet(EntityPropertyNames.MyProp)]
    public void MyProp_AfterGet(IbCore.PropertyInterceptorArgs<MyClass, String> args) {
      var value = args.Value; 
      if (!String.IsNullOrEmpty(value)) 
      { args.Value = GetDisplayValue(value);
      }
    }

and in SL I use the query with filter on this property

qry = from obj in MyData.MyClassContainer
where qry.MyProp == "xxx"

The query result is always empty whether I use for filtering ("xxx") "display" value or original "stored" value. What you can propose?



Replies:
Posted By: sbelini
Date Posted: 26-Feb-2013 at 10:57am
MaksimK,

Because you are changing the property value, a query against the DataSource will have different results then a query against the cache.
The default FetchStrategy is Optimized/DataSourceThenCache and that's why you aren't getting any results.

The options are:
1) Change the query's FetchStrategy to DataSourceAndCache;

2) query using DefaultQueryStrategy (DataSourceThenCache) on both values; (where qry.MyProp == originalValue || qry.MyProp == displayValue )

you could also:
3) query against the datasource only (qry.With(QueryStrategy.DataSourceOnly) using the original value;

4) query against the cache only (qry.With(QueryStrategy.CacheOnly) using the display value;

You will find more information about query strategies at http://drc.ideablade.com/xwiki/bin/view/Documentation/query-strategy - http://drc.ideablade.com/xwiki/bin/view/Documentation/query-strategy .


Posted By: MaksimK
Date Posted: 27-Feb-2013 at 3:51am
Thank you for assistance very much. 

What filter condition must be used in the first case (original or displayed value)?


Posted By: sbelini
Date Posted: 27-Feb-2013 at 8:40am
If you're querying DataSourceAndCache, either value will work.



Print Page | Close Window