Skip to content

How to map a List<Object> and loop through it while writing  #96

@marceladjanoh

Description

@marceladjanoh

I have to generate a fixed-length text file. How can I map a list of object in my main model? Let's assume that I have the following models:

   public class Employee
    {
        public string LastName { get; set; } = string.Empty;
        public string FirstName { get; set; } = string.Empty;
        public string Title { get; set; } = string.Empty;
        public Address EmployeeAddress { get; set; }
        public List<Child>? Children { get; set;}
    }
    public class Child
    {
        public string? ChildName { get; set; }
        public int Age { get; set; }
        public string Sex { get; set; } = "M";
    }
  1. How can I map the List Children using FixedLengthTypeMapper ?
  2. I have a list of employee to write in the text file and while looping through every employee, if an employee has children, I need to loop through all the children and write them before moving to the next employee. In this kind of scenario, what can be the efficient way to do the writing.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions