New Posts New Posts RSS Feed: Problem with property interceptors and queries
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Problem with property interceptors and queries

 Post Reply Post Reply
Author
MaksimK View Drop Down
Newbie
Newbie


Joined: 25-Feb-2013
Posts: 6
Post Options Post Options   Quote MaksimK Quote  Post ReplyReply Direct Link To This Post Topic: Problem with property interceptors and queries
    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?
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: 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.


Edited by sbelini - 26-Feb-2013 at 11:06am
Back to Top
MaksimK View Drop Down
Newbie
Newbie


Joined: 25-Feb-2013
Posts: 6
Post Options Post Options   Quote MaksimK Quote  Post ReplyReply Direct Link To This Post 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)?
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: 27-Feb-2013 at 8:40am
If you're querying DataSourceAndCache, either value will work.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down