Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Design advice re: generic BizObj.Search()
Message
 
À
23/12/2003 16:47:00
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Divers
Thread ID:
00861705
Message ID:
00861784
Vues:
18
Thanks, Bonnie. I started going the HashTable route for now, mostly because I thought there may be less overhead involved in processing that than a DataSet or XML document (but that's only a WAG, not a tested fact). So far, the HashTable also seems to me to be an easier interface to deal with on the UI side, which is what I was looking for. Basically, the UI has code that looks like this:
using System.Collections;

Hashtable searchHash = new Hashtable();

// Add criteria to search on each data-element provided.
if (txtLastName.Text.Length > 0)
  searchHash.Add("LastName", txtLastName.Text);
if (txtFirstName.Text.Length > 0)
  searchHash.Add("FirstName", txtFirstName.Text);
if (txtAccountNo.Text.Length > 0)
  searchHash.Add("AccountNo", txtAccountNo.Text);
if (txtPhoneNo.Text.Length > 0)
  searchHash.Add("PhoneNo", txtPhoneNo.Text);

// Request the search, passing the hashed search criteria and
// receiving a DataSet (or null). Update the display either way.
Session["clientListDS"] = Client.Search( searchHash );
if (Session["clientListDS"].GetType() == typeof(System.Data.DataSet))
  {customerList.DataSource = Session["clientListDS"];}
else
  {customerList.DataSource = "";}

customerList.DataBind();
The Client.Search() method uses foreach to process the HashTable entries and could, although it currently doesn't, translate "English" to columns names, etc.

So far though, everything is being ANDed and all of the operators are =. In the end, I likely will end up needing to go the Xml or DataSet route to allow for more flexibility without having to overload and parse the HashTable values.

I suppose (thinking out loud) that the key might be for me to create something like a custom SearchCriteria class with a method or two that allows the client code to easily add the search criteria, similar to the above. Then the "complexity" of working with the DataSet or Xml can be hidden in that class and can also be hidden from the "server" code. Sort of like a queue -- the client puts criteria in and the server takes them out to process. That object's "Add" method can even do the checking for an empty value and avoid adding that criterion, allowing the UI to just have one line per search control. Cool.

Thanks very much for providing advice and a sounding board here. I'd still be interested to hear (read) what others may have done for something like this -- assuming anyone else feels like reading my long posts, that is. :)

Kelly

>I used a similar approach to your XML idea, but I used a DataSet instead (which can be serialized to XML)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform