Value being overwritten on every call of the class

Source: www.stackoverflow.com

I am using filehelpers and I am generating a guid on the start of the read in from the class however the guid is being changed on every call that is not what I want I want when it first assigns the data to the file helper class it holds the guid for that row.

The class I am using

[DelimitedRecord(",")]
[IgnoreEmptyLines]
public class FuelPumpData
{
    [FieldHidden]
    private string  _guid;

    [FieldHidden]
    public  String Code
    {
        get
        {
            return _guid ?? (_guid = Guid.NewGuid().ToString("N")); 
        }
    }
    [FieldQuoted]
    public string Date { get; set; }
    [FieldQuoted]
    public string Time { get; set; }
    [FieldQuoted]
    public string CustomerName { get; set; }
    [FieldQuoted]
    public string CustomerName2 { get; set; }
    public string SystemGroup1 { get; set; }
    [FieldQuoted]
    public string CardCode { get; set; }
    [FieldQuoted]
    public string SystemGroup4 { get; set; }
    public decimal FuelQty { get; set; }
    public decimal FuelValue { get; set; }
    [FieldQuoted]
    public string FuelType { get; set; }
    [FieldQuoted]
    public string SiteName { get; set; }
    [FieldQuoted]
    public string Pump { get; set; }
}

As you can see I am generating the guid ok but without the dashes but I dont believe correctly as its being over written every time.

As I am of course using file helpers I will show my method here.

 var engine = new FileHelperEngine();
 var productSales = engine.ReadFile(Filename);

When I go to query my table for the guid that is in the code its not there at all and that is because I beleive I am creating a new guid every time in my class when i want it to retain its value for that row.

Read More Here, go to stackoverflow Author of this News
Author: Dave

Leave a Reply

Your email address will not be published. Required fields are marked *