c# - Return SQL to Generic List Automatically -
i have function connects database , extracts data.
the data returned expando object.
i convert expando object class, linq statement on dynamic line however, wondering if had class of fields in sql code, there way system automatically map each field in class?
i.e.
public list<clientall> fulltableclients() { const string abstractstatement =@"select * client clino = '0000001'"; var sqlstatement = new sqlstatements(abstractstatement, _reportingbackoffice.generatetables); var data = _reportingbackoffice.executequery(sqlstatement); var name = (from dynamic line in dataarray select new clientall() { clientnumber = line.????? //normally write line.clientnumber }).tolist(); return name; }
as can see above, need way reference field name in class , use variable when assign line?
thanks,
david
if have linq2sql datacontext can write:
const string abstractstatement = @"select * client clino = '0000001'"; using (var db = new mydatacontext()) var col = db.executequery<clientall>(abstractstatement).tolist();
it map columns form sql statement properties in clientall
Comments
Post a Comment