Subsonic Delete Example

B3y steven 1/19/2009 6:51:00 PM

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);

qryDelete.Execute();[/code]

Syntax highlighting, ftw! Hurrah!

Tags: , ,

Subsonic Simple Select and IDataReader Magic

B3y steven 1/19/2009 5:55:00 PM

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]

Tags: , ,

Powered By BlogEngine Enhanced with Snapshots

About the author

Steven Hildreth Steven Hildreth
Proof that anyone can setup a blog.

E-mail me LinkedIn Profile

Send mail Sign in

Recent posts