You can take advantage of the new dynamic features of C# 4.0, and use a DynamicObject as dto. It makes databinding even more 'ducky typed'. All you have to do, is to use the overloaded function Fetc or FetchOne and NOT provide a type or a map.

Now You can use it in all Fetch commands in MicroDal. F.ex. with Fetch:

        foreach (var item in DataSession.Current.Fetch(@"SELECT * FROM Address"))
        {
            sb.AppendLine("\t\t<tr class='gradeC'>");
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.id);
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", string.Format("{1}, {0}", item.fornavn, item.efternavn));
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.fornavn);
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.efternavn);
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.adresse1);
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.adresse2);
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.postnr);
            sb.AppendFormat("\t\t\t<td>{0}</td>\n", item.telefon);
            sb.AppendLine("\t</tr>");
        }


Thats it - use it with caution - it's a very powerfull option, and You won't see compileer check errors.

Last edited Aug 18, 2011 at 12:12 PM by TheIMan, version 7