Print Page | Close Window

Querying Custom Properties of Business Objects

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=124
Printed Date: 19-Apr-2025 at 8:31am


Topic: Querying Custom Properties of Business Objects
Posted By: jozza
Subject: Querying Custom Properties of Business Objects
Date Posted: 11-Jul-2007 at 10:50pm
Hi,
Is it possible to somehow query the PersistenceManager based on the value of some kind of custom property on a business object? eg. If we have a custom property called Age, is there a way to return all entities with an Age greater than say, 50?
 
I can sort of see how this sort of query would be a problem, since if the Persistence Manager needs to go back to the datasource to retrieve the data it probably can't create the appropriate query.
 
So the next question is, if we do need to have a query of this type what is the best way of retrieving data from the PersistenceManager?  One solution that I've thought of is to query the data as best I can based on actual EntityColumns and then given the EntityList write a delegate with the predicate based on the custom properties. I'm not sure how efficient this would be in large record sets though.
 
I'd be interested in hearing any other solutions. Thanks.



Replies:
Posted By: davidklitzke
Date Posted: 12-Jul-2007 at 8:45am
Jozza,
 
No.  It is not possible to make a query using a custom property.  The problem, as you correctly surmise, is that the query may need to go back to the database, and the database has no understanding of custom properties.  We have thought of supporting cache-only queries that use custom properties, but that is an extremely difficult feature to implement.  We may support cache-only queries that support custom properties after we support Orcas, but I make no promises.
 
The solution that you propose of using a predicate on a query that contains only entity columns is often your best approach.
 
Hera are some other solutions:
 
In your example of Age, you could translate the query to an equivalent query that used BirthDate
 
You could use a StoredProcRdbQuery
 
You could use a View



Print Page | Close Window