c# - What should we use when initializing some values from DataTables -


What should be more appropriate when you want to start class properties with datasheets.

i.e.

  name = dt.rows [0] [0] or name = dt.rows [0] ["name"]  

Which approach is more I use another approach to handle any easy scalable current, but it seems that if I use indexes instead of names, then I only need to convert that UI into stored processes.

But the readability of the code compromises, so what do I need for

? One option is to do something in between:

  personal const int name column = 0; ... name = dt.rows [0] [NameColumn];  

This lets you change the position of a if the column order / definitions change but also gives the readable code at the time of access. I'm not sure that it addresses the problem of changing both UI codes and stored procedures at the same time: If your SP is effectively changing its public interface, then you hope < / Em> should code However, this approach can reduce the pain of that change, as well as not cover your code with magic values.

(You can also consider strongly typed dataset ... or going to a non- DataTable data solution such as in the Entity Framework It may not be appropriate in your situation, but it is appropriate to think about it.)


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -