Wednesday, February 01, 2006

.norm update usage

Using .norm to update database records is almost as easy as inserting new records.
Foo user = new Foo();
user.FirstName = "Jay";
user.lastName = "Fields";
user.ID = 0;

ConnectionInfo info = new ConnectionInfo("data_source","my_catalog","user_name","password");
DataGateway gateway = new DataGateway(info);
WhereBuilder where = new WhereBuilder("ID",user.ID);
.norm will use type infomation or attributes to map your class to a table exactly the same way I previously documented.

The Update method takes an object and a WhereBuilder instance. The object is the object who's data will be used to update the database. The WhereBuilder instance is used to limit which records are updated. In the example above, only the rows in the database where the ID column is equal to 0 (the user.ID) will be updated. WhereBuilder has an And method that allows you to chain multiple equality tests.

No comments:

Post a Comment

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