Subsonic Simple Select and IDataReader Magic

Simple code snippet on using Subsonic Query for selecting data back.

[code:c#]

SubSonic.Query qry = new SubSonic.Query(Usr.Schema);
qry.SetSelectList(Usr.Columns.UserPkid);
qry.QueryType = SubSonic.QueryType.Select;
qry.AddWhere(Usr.UsernameColumn.ColumnName, SubSonic.Comparison.Equals, Username);

using (IDataReader reader = qry.ExecuteReader())
{
    while (reader.Read())
    {
        userpkid = long.Parse(reader[Usr.Columns.UserPkid].ToString());
    }
}

[/code]

Comments

comments

0

Leave a Reply