Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

I need to build a tiny mapping object around a SQL Query

I need to build a tiny mapping object around a SQL Query


I am looking for some best practice ideas...


I will build a little object which maps between two formats of warehouse ID, and make that object into a Singleton, with a DataTable at the center of it, and use that Singleton throughout my app. 


Here is a sample query:

select DISTINCT(ID), WAREHOUSENAME from MyWarehouses


I expect the results to look like this:


ID (INTEGER) NAME(String)

2                      'WH1'

15                    'WH2'

27                    'WH3'


I need the object to initialize itself with this query and to set the private DataTable. Then, to publicly expose two methods:


public string GetWarehouseName(int id);

public int GetWarehouseId(string name);


I expect to use the following logic inside each method:

string whName = (string)productRow["WAREHOUSENAME"];    


since I am only looking for a single returned value.


What suggestions can you make thus far on Best Practices? I expect to make this use this object as a Singleton, and want to make sure I am not missing something.


Thanks.

ASKER CERTIFIED SOLUTION
Avatar of dfke
dfke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

That is an interesting thing. Could you please elaborate on those two thread-safe options?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial