ha1o wrote:
Otis wrote:
You could ask the security object to produce that predicate expression for you so you can add it.
This is what I was trying to do. But the PredicateFactory class is in the DatabaseGeneric Proyect, so I cannot create a class which alter the filterBucket just by inherit from the DataAccessAdapter class.
You don't need the PredicateFactory to create predicates . If you have an entity, you can use the fields in that entity to produce a filter, using FieldCompareValuePredicate instances for example.
Though what I was refering to was: the security object is in a separate project, it has a reference to your dbgeneric project, and your dbspecific project has a reference to your security project. the dataaccessadapter derived class calls the security object, which produces the extra filter, and the dataaccessadapter derived class then moves on like nothing happened.
Maybe I was the one that didn't explain right the situation. The security class is standard for all applications, depends of who is the user, the security object will have an entity field name and a array of string with possible values that the field can have. So I have a field name and an array of values. My idea is like add something like this:
(" AND " + keyField + " IN (" + for(values[cont]) + ")")
to the filterBucket. As I said, I tried to use the predicate expression but I didn't find a way to do it without binding the new class to a DatabaseGeneric proyect; and I cannot do this because the security must be generic for all the systems and their databases.
Ok.
You could do this. myEntity is the entity to fetch, values is an array (or arraylist) of values.
To produce the filter above do in your security object's method, which receives an IEntity2 object, myEntity, and then selects the list of values to apply:
myFilter.AddWithAnd(new FieldCompareRangePredicate(myEntity.Fields[keyFieldName], null, values));
After that myFilter has the range filter applied to it. To be sure that the persistence info is filled in, you have to add this predicate a.s.a.p., so OnFetchEntity is too late for example.
This way, it doesn't require a reference to your dbgeneric project, as you use generic code from the ORMSupportClasses