CosmicCharlie
Programmer
I am developing a data tier for the first time, using the Abstract Factory design pattern. I have a working set of classes that return DataTables, DataReaders, and DataRows. I am also designing a Data Object, inherited from an abstract class, to support handling data for specific tables. The idea behind the Data Object is that it is dedicated to a single table, though nothing enforces this. Internally the data object calls various CRUD stored procedures associated with the table.
The problem I have is knowing how to design the data object so that it will support flexible searches of the table. Suppose it is a Customer table, and a user may want to search by Customer Name and State, or by City only, or any other combination of criteria. I cannot think of an elegant way to support this. I could create a WhereClause property, but that would require the client to have too much knowledge of the internal database design. It would also require me to use SQL commands in code, which I am trying to avoid.
I also considered creating a Parameter subclass in my data object, then creating a stored procedure with an optional parameter for every field. This would work, except I get stuck on how to handle numeric fields. I know of no numeric wildcards like there are for strings.
Is there any way to elegantly allow users search on any combination of fields they like without sacrificing solid OO design?
Charlie
The problem I have is knowing how to design the data object so that it will support flexible searches of the table. Suppose it is a Customer table, and a user may want to search by Customer Name and State, or by City only, or any other combination of criteria. I cannot think of an elegant way to support this. I could create a WhereClause property, but that would require the client to have too much knowledge of the internal database design. It would also require me to use SQL commands in code, which I am trying to avoid.
I also considered creating a Parameter subclass in my data object, then creating a stored procedure with an optional parameter for every field. This would work, except I get stuck on how to handle numeric fields. I know of no numeric wildcards like there are for strings.
Is there any way to elegantly allow users search on any combination of fields they like without sacrificing solid OO design?
Charlie