|
|
IRWDataObject's code to update record in Student - table
Update data/table using criteria(s) with new data as an object.
string sqlConnectionString = "...";
// define update-schema for Student class
UpdateSchema sc = new UpdateSchema(typeof(Student), null);
// update record with criteria ID
// define where-schema for fields ID with default value
WhereSchema ws = new WhereSchema(sc);
ws.Add(SqlConditional.And, typeof(Student), typeof(Student),
"Name", SqlComparison.Equal, "Andrew");
// define new Student object with update information
Student record = new Student();
record.Name = "Update-Student";
record.ClassID = 2;
record.DOB = new DateTime(1991, 3, 15);
// define mapper object
UpdateMapper m = new UpdateMapper(sqlConnectionString, sc);
// execute update-schema with new Student-object
int result = m.Execute(record, null);
Console.WriteLine("Update result : {0}", result);
|
|
|