Popular data programmatically x manually

4

You can populate data from a component in .NET using Visual Studio's interface (Select DataSource ...).

  • From the standpoint of popular performance data via code is faster than manualmentr?
asked by anonymous 24.03.2014 / 12:58

2 answers

2

There should be no difference. What Visual Studio does when you select a DataSource through its GUI is to generate the join code automatically. You could write this code yourself. There will only be performance differences if you are setting up your DataSource manually and in some inefficient way.

If you expect the database to change, it is best to abstract as much as possible building the DataSource. It is also preferable to leave the connection data in a configuration file, in this case. Or somewhere else where you can easily change that data without having to recompile the program.

    
24.03.2014 / 13:03
2

Laerte, when you populate your DropDown via code, you gain in abstraction because you can decouple the business rule from the database through DataSource.

For example, if you have an application today in a SQL Server database and tomorrow you find that you need to migrate the database to an Oracle and do not tinker with your table structure, if you populate all your DropDown DataSource when migrating , you will have to redo them on hand to use another provider. If you do via code, with a well-structured and separate architecture and using a generic data access layer, you will almost not have to tinker with your code, depending even on eg ORM you use, you may need to just change the path database connection.

    
24.03.2014 / 13:08