Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

foreach inside arrays

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.
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.
[Image: vp6iypF.gif]
(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
(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.
[Image: vp6iypF.gif]
(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


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by pzychonautJun 8, 2023 05:03 PM 5 176 Jun 8, 2023 05:03 PM
Last Post: padrino
[C] by EmacsSucksButILikeItJun 4, 2022 11:03 PM 1 222 Jun 4, 2022 11:03 PM
Last Post: unazed
[Java] by PsychoJul 3, 2021 11:15 PM 24 1,975 Jul 3, 2021 11:15 PM
Last Post: Lookdadon