Hi Walaa,
Thanks for your reply.
I think you just need to fetch the entity before updating it.
Sorry, that's not an option. First of all, performance is critical here. The code I'm working on is executed very often. The reason we're trying to implement LLBLGen here is to get better performance. We also want to reduce the number of roundtrips over the network and to the database.
Also, It would not even solve my problem. Because, when I fetch it and change the primary-key, it won't update anymore. LLBLGen will know for a fact that the primary key has changed, so it will look for a record with the old values. But that's not what I need here. The primary key fields should have a unique value in the first place in order for this to work. In my case the fields are not yet populated. I need LLBLGen to look at the identity-field (other field that PK) to match for a record to update.
If the PK is changed and IsNew is set to false, LLBLGen won't do anything. IsNew = false will cause LLBLGen not to insert and the changed PK causes LLBLGen not to update.
This thread comes close to my problem:
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3064
Frans says:
_The problem is, the code generating the query has to formulate a filter on the PK. (to find the row to alter). If you just set the PK field of a new entity, it will think (it has to) that the PK set in the entity is the one to use for the filter.
To ALTER a PK, you have to alter an existing's entity's PK field. This way, DbValue is set as well. This then means that the query generator can find back the row to alter. You run into a check in FieldCompareValuePredicate, where it tries to determine which value to use._
I would like the piece of code in the query generator, which formulates the filter and which Frans is talking about here, to look at the identity-field instead of the primary-key.
I hope someone knows a solution for this.
Thanks!
René