Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:47:23+00:00 2026-06-12T20:47:23+00:00

I’m running into what appears to be unexpected behavior when utilizing the FieldNotInFile attribute

  • 0

I’m running into what appears to be unexpected behavior when utilizing the FieldNotInFile attribute in my mapping file. Please see below, abbreviated examples of what I have configured.

The mapping for the header record is defined separately to keep the option open for MasterDetail engine:

public class HeaderMapping
{
    public string ID;
    public DateTime RptDateFrom;
    public DateTime RptDateTo;
    public DateTime GenerationDate;
....
}

I would like to combine the values retrieved from the header into the final record result so they are specified with the FieldNotInFile attribute to be added later.

public class RecordMapping
{
    // Values not in source
    [FieldNotInFile()]
    public string ID;
    [FieldNotInFile()]
    public DateTime RptDateFrom;
    [FieldNotInFile()]
    public DateTime RptDateTo;
    [FieldNotInFile()]
    public DateTime GenerationDate;

    // Start values from source
    public string RowPrefix;
    public string Field1;
    public string Field2;
    public string Field3;
....
}

In the engine execution I have defined two instances. The first to capture the single header record and parse out its values. The AfterReadRecord event is used to stop the engine after the first line.

static void Main(string[] args)
{
    // Extract the header
    FileHelperEngine<HeaderMapping> headerEngine = new FileHelperEngine<HeaderMapping>();
    headerEngine.AfterReadRecord +=
        new FileHelpers.Events.AfterReadHandler<HeaderMapping>(AfterHeaderRead);

    HeaderMapping[] headerRecord = headerEngine.ReadFile(source.FullName);

    // Capture Values
    companyId = headerRecord[0].ID;
    rptDateFrom = headerRecord[0].RptDateFrom;
    rptDateTo = headerRecord[0].RptDateTo;
    generationDate = headerRecord[0].GenerationDate;
....

Next the record engine is created. The BeforeReadRecord event is used to insert the previously captured values into the placeholders signified in the RecordMapping with FieldNotInFile attributes.

....
    // Extract the Records
    FileHelperEngine<RecordMapping> recordEngine = new FileHelperEngine<RecordMapping>();
    recordEngine.BeforeReadRecord +=
        new FileHelpers.Events.BeforeReadHandler<RecordMapping>(BeforeThisRecord);

    DataTable outputTable = recordEngine.ReadFileAsDT(source.FullName);
}
....
private static void BeforeThisRecord(EngineBase engine, BeforeReadEventArgs<RecordMapping> e)
{
    e.Record.ID = companyId;
    e.Record.RptDateFrom = rptDateFrom;
    e.Record.RptDateTo = rptDateTo;
    e.Record.GenerationDate = generationDate;
}

The outputTable result is not as expected. The fields marked as FieldNotInFile are completely omitted from the DataTable result. When debugging the process, the BeforeThisRecord method executes correctly and assigns the appropriate values but this is not reflected in the output. The DataTable columns are output as RowPrefix, Field1, Field2, etc. and not ID, RptDateFrom, RptDateTo, GenerationDate, RowPrefix, etc.

Strangely when I use the alternate method..

List <RecordMapping> recordList = recordEngine.ReadFileAsList(source.FullName);

The list items contain the RecordMapping objects with ALL of the correct values. It seems as though the DataTable translation of FieldNotInFile attributes is the culprit. Am I doing this wrong? Is this a bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:47:24+00:00Added an answer on June 12, 2026 at 8:47 pm

    You are correct that ReadFileAsDT() does not include the FieldNotInFile fields in the DataTable. It might be a bug, but honestly, I’m not sure how FieldNotInFile is supposed to be used – it’s not in the documentation here.

    I think you’re better off using the Master Detail engine or alternatively just doing

     RecordMapping[] recordMappings = recordEngine.ReadFile(source.FullName);
    

    and then if you really need a DataTable, populate it yourself with something like:

    DataTable outputTable = new DataTable(); // New data table.
    outputTable.Columns.Add("ID", typeof(int)); // Add all columns.
    outputTable.Columns.Add("RptDateFrom", typeof(DateTime));
    outputTable.Columns.Add("RptDateTo", typeof(DateTime));
    outputTable.Columns.Add("GenerationDate", typeof(DateTime));
    outputTable.Columns.Add("RowPrefix", typeof(String));
    outputTable.Columns.Add("Field1", typeof(String));
    outputTable.Columns.Add("Field2", typeof(String));
    outputTable.Columns.Add("Field3", typeof(String));
    
    foreach (RecordMapping recordMapping in recordMappings)
    {
      outputTable.Rows.Add(
        companyId, 
        rptDateFrom, 
        rptDateTo, 
        generationDate, 
        recordMapping.RowPrefix, 
        recordMapping.Field1, 
        recordMapping.Field2, 
        recordMapping.Field3)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.