fluent nhibernate - Re-applying a FilterDefinition -


i have application models electrical distribution of system whereby if of components fail routing automatically rerouted. i've modelled adding connection entity has id parent component , id child component. idea items may fail there connection normal working condition , connection each failed situation. example, if there 40 components of 9 may fail have 2^9 (512) possible failures , 2^9 connection entities each component. each connection named failure mode represents.

so far, good, flexible , works.

however, every time bus diagram loaded connections loaded resulting in 40 * 512 (20480) connection entities when 40 needed current failure mode and, not surprisingly, causing application hog resources , run slowly.

so, have defined filterdefinition restrict connections loaded required named connection if component of particular type , normal connection if other type , added connections collection mapping of component enabled filter , set parameter.

public failuremodefilter() {     withname("failurename")         .withcondition("((name = :name , objecttype <> 8) or                           (name = 'normal' , objecttype = 8))")         .addparameter("name", nhibernateutil.string); } 

and not @ surprisingly, works.

but, , knew there going snag didn't you?

but, when new failure mode chosen , diagram reloaded, doesn't apply new filter retains old one. i've tried setting new parameter, disabling filter, enabling again , setting pararmeter no avail.

so, doing wrong/failing do/misunderstanding (delete applicable) or, failing that, suggestions how solve this?

the same session being used while diagram open. yes, know isn't suggested best practise, other reasons best solution part of application. please don't side-tracked telling me how bad practise doom, gloom , depondency know. question changing of filter.

answered own question change.

this answer refresh component force reload database.

session.refresh(entity); 

so simple when figure out!


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -