views:

49

answers:

1

For other reasons, i've had to create my own property in an Entity in the ORM, which has is a type of another entity (had issues with associations so did it this way instead).

The problem is that whenever I make a change to that property, it isn't being flagged as a change so I cannot call SubmitChanges on it.

So basically my question is, is there a way of forcing a property to be tracked for changes for when I call SubmitChanges?

thanks.

A: 

Does your custom property have a corresponding field in the database?

I would try adding your field to the database first. Delete the entity from the Linq2SQL designer, save the designer file, drag the table back to the designer from the Database Explorer, and save again. This will recreate the entity with your desired property, and insure that all of the hooks are in place for SubmitChanges().

Robert Harvey
That would probably work, however the property i've added is of a custom type i.e. MyEntity not string or int
HAdes
For that, you need another table in the database containing the MyEntity fields, with a Foreign Key pointing to your original table's Primary Key.
Robert Harvey
Then, drag your new table to the Linq2SQL designer, thereby creating another entity.
Robert Harvey
yes that's effectively what i have already, but the property MyEntity in my first entity doesn't seem to be tracking changes to any of it's fields.
HAdes
I would need to see a little more detail to know what is going on. A picture of your two entities in your entity diagram would help.
Robert Harvey