Subsonic Delete Example

Subsonic seems to be really all that for DAL (Data Access Layer). In this example I have a table named “DvdNote” that a struct was generated by the Subsonic SubCommander tool.

Example on how to perform a delete statement;

[code:c#]                    SubSonic.Query qryDelete = new SubSonic.Query(DvdNote.Schema);
qryDelete.QueryType = SubSonic.QueryType.Delete;
qryDelete.WHERE(DvdNote.Columns.DvdnotePkid, this.Identity);


Syntax highlighting, ftw! Hurrah!

Subsonic Simple Select and IDataReader Magic

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


SubSonic.Query qry = new SubSonic.Query(Usr.Schema);
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());