i have inherited c# (wpf) project part of code user friendly ui (list boxes, radio buttons,sliders, etc.) non sql person creates sql query statement ... queries db , returns results.
the code create sql walks thru ui components , concatenates string.
i'm slowing finding either bugs in code and\or misinterpretations of needed.
i want update code more elegant , maintainable state. there any:
- 'design patterns' this?
- best practices?
- examples of code?
thanks
many wrote code when .net started; there indeed many design patterns move on this.
firstly, project mixes c# , sql syntax. separate halve code size , double elegance. remove sql injection possibilities.
identify final sql typically looks like. might be
select a,b,c d join e join f x , y , zwrite stored procedure on sql side encapsulate this, passing parameters x, y , z
change c# code call stored procedure instead of sql statement
c# debugging can involve viewing parameters end when call sql statement
on sql side, next step move table joins , static clauses view, further simplify stored procedure , give sql server more opportunity pre-optimise data selection.
good luck
Comments
Post a Comment