C
ChrisB
Hello:
I am writing an application using C# that needs to support several queries
that
limit the number of returned records through the use of filtering and was
hoping to get some opinions on the best way to set up the necessary class
interfaces.
For example, Customer.GetCustomerList() might require 2 filters such as a
"StateID" filter which is a Guid and and "IsActive" filter which is a
Boolean. So, the method signature would look something like this:
GetCustomerList(Guid StateID, Boolean IsActive). The main issue I am
encountering is how to allow the user to specify that no filtering will be
used.
One option is: GetCustomerList(Boolean UseFilterByStateID, Guid
StateID, Boolean UseFilterByIsActive, Boolean IsActive). The related stored
procedure could then use all 4 pieces of information to return the proper
records.
Another option would be to allow users to provide a"special" value to a
filter to indicate that it should not be used. Although this might work for
a Guid filter (say, '{11111111-1111-1111-1111-111111111111}' = dont use
filter), there is no
way to indicate "no filter" for a boolean filter.
I am leaning toward the first option but would appreciate any
input. Is there a common technique for handing this type of requirement.
Have there been any helpful articles written on the subject?
Thanks!
Chris
I am writing an application using C# that needs to support several queries
that
limit the number of returned records through the use of filtering and was
hoping to get some opinions on the best way to set up the necessary class
interfaces.
For example, Customer.GetCustomerList() might require 2 filters such as a
"StateID" filter which is a Guid and and "IsActive" filter which is a
Boolean. So, the method signature would look something like this:
GetCustomerList(Guid StateID, Boolean IsActive). The main issue I am
encountering is how to allow the user to specify that no filtering will be
used.
One option is: GetCustomerList(Boolean UseFilterByStateID, Guid
StateID, Boolean UseFilterByIsActive, Boolean IsActive). The related stored
procedure could then use all 4 pieces of information to return the proper
records.
Another option would be to allow users to provide a"special" value to a
filter to indicate that it should not be used. Although this might work for
a Guid filter (say, '{11111111-1111-1111-1111-111111111111}' = dont use
filter), there is no
way to indicate "no filter" for a boolean filter.
I am leaning toward the first option but would appreciate any
input. Is there a common technique for handing this type of requirement.
Have there been any helpful articles written on the subject?
Thanks!
Chris