Extend Coconut Dal

You can implement the ICoconutDal interface and make your own Coconut Dal's for other database providers. Or you can extend an existing Dal if you need to cache data, for example:

 

public class MemcacheCoconutDal : SqlServerCoconutDal
{
    public override object GetSingleValue(string command, params[] parameters)
    {
        // check cache, if empty get fresh data
        object result = base.GetSingleValue(command, parameters);
        // cache result
        return result; 
    }
}

 

If you use a dependency injection library such as Structure Map, you can indicate in web/app.config which implementation of ICoconutDal should be used at runtime.

Want DataReaders?

SqlServerCoconutDal has a protected method IDataReader GetReader, because we believe that a data layer should not expose a DataReader object. If you disagree, just derive a class from SqlServerCoconutDal and add a public method that calls the protected method. But be sure you close those readers!

Last edited May 31, 2012 at 6:22 PM by CoconutDev, version 1

Comments

No comments yet.