This project has moved and is read-only. For the latest updates, please go here.

Working with the Database Abstraction Layer

Nov 19, 2009 at 5:33 PM

How do I get a list of services in the local metadata cache?  I've tried the following code, but the count is zero.  This is from the existing code in the Metadata Fetcher plugin.


IList<CSDataService> serviceList = CSDataService.List().OrderedBy("ServiceEndpointURL");

MessageBox.Show(serviceList.Count.ToString()); // Returns 0

Nov 19, 2009 at 7:00 PM

Here's how I'm currently doing it.  I wonder if there's a better ORM way....


             DataTable servicesTable = _dbOperations.LoadTable("DataServices", "select ServiceEndpointURL from DataServices");
                foreach (DataRow row in servicesTable.Rows)

Nov 19, 2009 at 8:12 PM

The team has decided to use NHibernate instead of Vici.CoolStorage as the core of the database abstraction layer. This is still work in progress and needs some additional testing. You can find some of the initial source code in HydroDesktop/source/testing/NHibernateDataModel. The plan is to have this code integrated into HydroDesktop.Database.dll soon. Then it will be possible to have an easier way to communicate with the database.

If you're interested please examine the source code in HydroDesktop/source/testing/NHibernateDataModel. The basic idea is: there will be built-in functions which will return objects such as Site, Variable, DataService, DataSeries or DataThemes. When changing the properties of these objects within a transaction, the changes will be automatically written to the database on transaction commit.

Please stay tuned before the new database abstraction layer is available. It should be available in the next few days.



Nov 24, 2009 at 12:25 PM


I was wondering if there is an update on the database abstraction layer using NHibernate.  Is it far enough along to start using?  Are there examples (code snippets) available?




Nov 24, 2009 at 7:05 PM

Will the abstraction layer work for both the main database and the metadata cache database?  I assume there will be methods for adding data to the database and also deleting data from the database.  If that's the case, can we have a method that deletes all data associated with a given serviceID?  Or for a given siteID?  Etc.




Nov 25, 2009 at 4:13 PM

Jon and Time

Thank you for your suggestions.

Yes, the abstraction layer will work for both the main database and the metadata cache database. A method that deletes all data associated with a given serviceID, siteID or variableID will be included.

The abstraction layer is getting ready. Before it is released the following decision needs to be made:

A) Use the very generic object model proposed by David Valentine and make some modifications to the existing HydroDesktop database schemas.

B) Use a simplified object model more compatible with the current HydroDesktop database schema.


My vote is for B) but the Cuahsi team should decide.



Nov 30, 2009 at 6:19 PM

I vote for simple. Hence B) might be better. However tomorrow when Jiri and Justin work on this in Logan with Jeff, I'll be willing to work with whatever design the three of them settle on. - Dan