Hack Forums
[C#] foreach inside arrays - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] foreach inside arrays (/showthread.php?tid=6106124)



foreach inside arrays - antibiotic1 - Aug 30, 2020

Code
ListPerson data = new ListPerson
            {
                Person = new PersonDetails[]
                {
                        new Person
                        {
                            Name = "1",
                            Surename = "2",
                            Age = "3",
                            Address = new AddressList[]
                            {
                                new Address
                                {
                                  
                                        Name = "5",
                                        Number = "6",
                                        City = "7"
                                        
                                }
                            }
                        }
                    }
            };

I have this code that i use to built xml with xml serializer and it works good for this example but with fixed values. My question is how can i write some code to make it to take values from dataset. lets say i have two database tables Person And Address and they are connected with id field. One client can have more addresses. As i think i will need to feel dataset with data(and this i know how) and then write a foreach code inside this arrays in order to make it to work.


RE: foreach inside arrays - MavenGradle - Aug 30, 2020

Don't reinvent the wheel. Use an ORM tool/framework like for example Entity Framework.

Datasets can be mocked for testing purposes using mocking tools. This will require that you follow the OOP and Inversion Of Control (IoC) principles.


RE: foreach inside arrays - draxyee - Sep 1, 2020

(Aug 30, 2020 06:45 AM)MavenGradle Wrote:  Don't reinvent the wheel. Use an ORM tool/framework like for example Entity Framework.

Datasets can be mocked for testing purposes using mocking tools. This will require that you follow the OOP and Inversion Of Control (IoC) principles.

Poor guy lol, you've probably spoken chinese to him, he's looking for a quick solution not to study the fucking coding bible lol


RE: foreach inside arrays - MavenGradle - Sep 1, 2020

(Sep 1, 2020 11:05 AM)draxyee Wrote:  Poor guy lol, you've probably spoken chinese to him, he's looking for a quick solution not to study the fugging coding bible lol

Test driven development (TDD), ORM frameworks and mocking frameworks/tools are some of the first things you see and learn about in university when it comes to programming, or at least it used to be back in the day.

For good reason too, they are extremely useful, robust and great for application development in general. They allow you to correctly test, develop and implement production grade software without losing too much time on trivial matters.

That is, if the basics of programming are understood by the practitioner. There will always be ways to mess things up, but these frameworks and tools exist to help prevent such situations. I suppose one who's 'skilled' enough can also mess up those frameworks and tools, if we disregard the possibility of bugs in said frameworks and tools.


RE: foreach inside arrays - Accord - Sep 1, 2020

(Sep 1, 2020 11:05 AM)draxyee Wrote:  Poor guy lol, you've probably spoken chinese to him, he's looking for a quick solution not to study the fugging coding bible lol

orm is a quick solution since he is talking about database