The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Incorrect column name passed around on serialization

Last post 03-27-2008, 3:13 PM by jeppe. 1 replies.
Sort Posts: Previous Next
  •  03-27-2008, 2:45 PM 8589

    Incorrect column name passed around on serialization

    I have a table with a single column, auto-incremented primary key.  I have a grid that is bound to an ES collection based on this table.  The collection is loaded up on a web service, serialized, deserialized on the client and bound to the grid.

    My problem is in regards to serializing the collection after deleting a row.  On calling the serialization method, I get the error "System.InvalidOperationException: There was an error generating the XML document. ---> System.ArgumentException: Column 'LopGlfinanestimatesKey' does not belong to table".  I'd seen this in regards to not including a certain field in the select part of the Query, but that doesn't apply as I most definitely have that field in my collection and on the grid.  I followed it through and saw that the error originated from a call to the "GetOriginalColumnValue" method (only done if the Entity had been marked as deleted):

     

    Code:
    if (this.Entity.es.IsDeleted)
    return (System.Int32?)this.Entity.
    GetOriginalColumnValue(LopGlfinanestimatesTblMetadata.PropertyNames.LopGlfinanestimatesKey);
    else
    return this
    .Entity.LopGlfinanestimatesKey;

     
    I've seen mention that the GetOriginalColumnValue method just queries the DataRow associated with it with a version specifier and the column name passed into it.  If that is the case, wouldn't I want to use the ColumnNames collection in this call as the DataRow uses them instead of PropertyNames?

    Anyway, this is my attempt to figure out why this isn't working.  I'm sure I'm just missing something obvious.  So, why can't that GetOriginalColumnValue method find my PrimaryKey column?  Thanks in advance, Adam.
     

  •  03-27-2008, 3:13 PM 8592 in reply to 8589

    Re: Incorrect column name passed around on serialization

    Ok, so I'm going to say (presumptuously) that the template code might be incorrect.  I think the proposition I made above is correct.  Here's the code to pick up the primary key for doing the deletion. 

    Code:
    public System.Int32? LopGlfinanestimatesKey
    {
    get
    {
    if (this.Entity.es.IsDeleted)
    return (System.Int32?)this.Entity.
    GetOriginalColumnValue(LopGlfinanestimatesTblMetadata.PropertyNames.LopGlfinanestimatesKey);
    else
    return this
    .Entity.LopGlfinanestimatesKey;
    }
    set { this.Entity.LopGlfinanestimatesKey = value; }
    }


    The if clause would evaluate to true for my deleted entity, and the "GetOriginalColumnValue" method would be called.  Based on the exception ("Column not found"), I have to assume that the "PropertyNames" being passed in is incorrect and should be "ColumnNames" which are the database columns themselves.  I'm sure that a lot of people use the same names for both Property and Column, but I don't.

    Anyway, I changed the "PropertyNames" to "ColumnNames", and it serialized just fine and accurately.  I've all ready changed my template for generation and propose that gets done for the next release, assuming I'm not out-of-date and this was picked up long ago!  Thanks.

    --Adam

     

View as RSS news feed in XML