Thursday, February 02, 2006

.norm delete usage

Using .norm to delete database records is very similar to updating records. The only difference between update and delete is that delete doesn't require an instance of a type. Instead, Delete takes a type as a parameter. Delete uses this type to remove all the records of that type that match the WhereBuilder clause.
ConnectionInfo info = new ConnectionInfo("data_source","my_catalog","user_name","password");
DataGateway gateway = new DataGateway(info);
WhereBuilder where = new WhereBuilder("ID",0);
gateway.Delete(typeof(Foo),where);
Following the execution of this code, all records in the database where the ID column is equal to 0 will be deleted. As expected, .norm will use type infomation or attributes to map the type to a table. IWhereBuilder usage is exactly the same as previously explained.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.