sql - C# SqlBuilder -- How to use Convert dynamically -
i have sql query:
select relationid , convert(date, receiveddate, 10) [date] , matdesc , sum(amount) , sku tablename relationid = 1000 group convert(date, receiveddate, 10) , relationid , matdesc , sku
which need write dynamically in c# sqlbuilder. far have:
selectquery qry = new selectquery("db"); qry.withnolock = true; foreach (exportcolumndefinition exportcolumndef in getexportcolumndefinitions()) { qry.selectcolumn(exportcolumndef.datafieldname); } qry.criteria.addexpressioncriterium("relationid= " + esetting.relationid); qry.criteria.addcolumncriterium("receiveddate", operator.greaterthanorequalto, datetime.now.adddays(-30)); qry.criteria.addcolumncriterium("receiveddate", operator.lessthanorequalto, datetime.now); qry.addorderbycolumn("receiveddate", sortorder.descending);
i'm new use kind of or documentation link. (couldn't find myself.)
-- small edit, i'm missing is: convert , sum.
edit apparently sqlbuilder we're using custom made, disregard question.
you don't need make unnecessary complicated. can write query in sqlcommand constructor.
sqlcommand cmd=new sqlcommand("your query", connetionobj); cmd.executescalar();
Comments
Post a Comment