jimph wrote:
Good to know your perspective, we do like things this and that for the problem at hand but not necessary best thing for the framework as the whole
MarkFieldsAsDirty() did not do what I hope for (not sure what it does), the fields did not get saved after setting IsNew and calling MarkFieldsAsDirty(). That is, I still need to set all fields as hasChanged() in order for them to be persisted.
True, it marks the FIelds object as Dirty, but not the fields inside it, this is mostly needed for IEditableObject, so not of use for your scenario.
We dont exactly want to clone as we just need to push the records, millions of them, to the database and done with.
Thanks
So in short, you want to do INSERT INTO Table1 SELECT f1, f2,..., fn FROM Table1 WHERE.... where the SELECT fetches the rows to insert but you specify different values for some fields? The question of course is: the values you want to change, are these values which are determinable inside the projection, so based on the values of the row, or are these values you have to read from somewhere else? If the former, you can specify a single INSERT statement to perform what you want. If the latter, you have to do it on the client, and indeed have to fetch the entities, copy the values you want, and re-insert the entity. Doing it on the client is likely going to be time consuming when you have to process millions of rows.
Could you elaborate a bit about the values you need changing and how the values you change are determined? because it's wise to go for the INSERT... SELECT statement (which we don't support out of the box, but you can define an IActionQuery to execute it) which runs once and which will copy your rows in 1 go on the DB server (so it will be much much faster)