i have table named 'department' , has 2 columns, 'deptid' , 'deptname'. have created properties that.
class departmentclass { public int did { get; set; } public string dname { get; set; } }
now, instead of using auto generated 'departments' class, want use above properties add entry.
departmentclass newdept = new departmentclass(); newdept.did = 120; newdept.dname = "shell scripting"; db.departments.insertonsubmit(newdept); //this has invalid argument db.submitchanges();
please let me know if there way make possible?
if have alot of these conversions make, might try automapper. it's free tool can map poco's data classes , vice versa. mappings once when app initializes, calls conversion simple i.e.
db.departments.insertonsubmit(mapper.map<departments>(newdept)); db.submitchanges();
https://github.com/automapper/automapper/wiki/getting-started
Comments
Post a Comment