Hi all,

Thanks Ron and Guilles.

Ooops, maybe I forgot to tell something important: I'm not using WebForms, but WindowsForms.

I'm not posting the exact code cause unfortunately it's in Spanish, but the idea is that I want some code like this to run on initialization, so I place it inside the constructor or on the load event:

ShiftsPanel.cs:

foreach (Shift s in (ArrayList) Shift.SelectAllShifts())
{
        this.listBoxShifts.Items.Add(s);
}


Shift.cs:

public static ArrayList SeleccionarTodosTurnos()
{
        return((ArrayList) Mapa.Instancia().SelectList(0, "SelectAllShifts"));
}

I've also got another layer using a singleton which is basically like iBatis, which tries to isolate my code from iBatis just in case I want to switch to another persistence framework or no persistence framework at all (just SQL sentences):

Mapa.cs:

public class Mapa
{
                                
// SINGLETON
                
private static volatile Mapa _mapa = null;
                
protected static void InitMapa()
{
        _mapa = new Mapa();
}
                
public static Mapa Instancia()
{
        if (_mapa == null)
        {
                lock (typeof (Mapa))
                {
                if (_mapa == null)
                        InitMapa();
                }
        }
        return _mapa;
}
                
// IBATIS
                
private SqlMapper Ibatis()
{
        SqlMapper m = Mapper.Instance();

        return(m);
}
                
// METHODS TO INTERACT WITH DATABASE
                
public IList SelectList(object param, string sentence)
{
        return(this.Ibatis().QueryForList(sentence, param));
}

...

} // End Mapa



And of course if that code on ShiftsPanel.cs is run automatically by the IDE, it follows the chain until it ends up calling Ibatis.

Thanks again,

Pablo.

Reply via email to