Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get Error Collection with raising Exceptions #2283

Open
abidkayanidefra opened this issue Aug 23, 2024 · 0 comments
Open

how to get Error Collection with raising Exceptions #2283

abidkayanidefra opened this issue Aug 23, 2024 · 0 comments
Labels

Comments

@abidkayanidefra
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

So what I am trying to do is Map a class with a Mapping class.

public class DataToLoad
{
public string Org_id { get; set; }

public string Org_name { get; set; }

public string Parent_child { get; set; }

public List<string> Errors { get; set; }

}

public DataToLoadMap(List errorLog)
{
if (errorLog == null)
{
errorLog = new List();
}

 Map(c => c.Org_id).Name("Org_id");
 Map(c => c.Org_name).Name("Org_name");
 Map(c => c.Parent_child).Name("Parent_child");
 Map(c => c.Errors).Convert(args =>
    {
        if (string.IsNullOrEmpty(args.Value.Org_id))
        {
            errorLog.Add(new CsvErrorModel { ErrorMessage = "Org_id is null" });
        }

        if (string.IsNullOrEmpty(args.Value.organisation_name))
        {
            errorLog.Add(new CsvErrorModel { ErrorMessage = "Org_id is null" });
        }

        if (string.IsNullOrEmpty(args.Value.companies_house_number))
        {
            errorLog.Add(new CsvErrorModel { ErrorMessage = "Org_id is null" });
        }

        if (string.IsNullOrEmpty(args.Value.parent_child))
        {
            errorLog.Add(new CsvErrorModel { ErrorMessage = "Org_id is null" });
        }

        return lerrorLog;
    });

returned errorlog is always null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant