IRWDataObject - .NET Object Relational Mapper
.NET Object Relational Mapper to Database

irwsoft.com


Home
IRWDataObject's code to delete record from Student - table

Delete record(s) using criteria.

string sqlConnectionString = "...";

// define delete-schema for Student class
DeleteSchema sc = new DeleteSchema(typeof(Student));

// delete record with criteria ID and Name
// define where-schema for fields ID and Name with default value

WhereSchema ws = new WhereSchema(sc);
ws.Add(SqlConditional.And, typeof(Student), typeof(Student), "ID", SqlComparison.Equal, 22);
ws.Add(SqlConditional.And, typeof(Student), typeof(Student), "Name", SqlComparison.Equal, "Andrew");

// define mapper object
DeleteMapper m = new DeleteMapper(sqlConnectionString, sc);

// execute delete-schema with default criteria
int result = m.Execute(null);

Console.WriteLine("Delete result : {0}", result);


Delete with different argument

// set criteria with array of object
Object[] where = new Object[] { 23,"Tina" };
...
...
// pass new criteria to Execute method
int result = m.Execute(where);


Note : should define where-schema to delete one record

Copyright by : IrwSoft © 2009 , All Rights Reserved