I have the following code which is in a base class.
MyApp.MyDB = new MyApp.MyDB ();
IRepository<T> repo = new SubSonicRepository<T>(db);
CurrentTable = repo.GetTable();
var s = db.SelectColumns(columnList.ToArray()).
From(CurrentTable.Name).
OrderAsc(CurrentTable.Descriptor.Name);
The idea is that all my classes can call this method.
I have just realised that I may need to a 'where' statement and there could be numerous columns names and values to test for.
What's the best approach for this?
UPDATE: I found this works below but is it best practice?
//WhereClause is a Dictionary<string, string>
int count = 0;
foreach (var whereitem in WhereClause)
{
if (count == 0)
{
s.Where(whereitem.Key).IsEqualTo(whereitem.Value);
}
else
{
s.And(whereitem.Key).IsEqualTo(whereitem.Value);
}
count++;
}