Drag&Drop of Entities

We need the possibility to drag&drop entities within different processes.

Therefor we implemented an entityconverter, that puts an entity into a stream, using TDataSnapJsonSerializer.

So the entity is serialized to JSON first. This JSON is put into a stream afterwards.

My first question is, is there an easier way to put an Entity into a stream?

Doing it this way, as we all know, there is a dragdrop effect called copy.
For this it would be really nice, if there is a callback, for changing datas for each MemberInfo.
So that for example IDs could be set to 0, so that new Entities would be created.

So my second question is, will this callback require a feature request, or would it easy to implement on your site?

Hi @Silber_Felix, sorry but I didn't understand your request.

You answered it yourself, you "convert" (or serialize) an entity to a text representation, like JSON, and then save that to stream. Then you deserialize the string to convert "text" back to an entity.

What does it had to do with drag and drop or callbacks, I don't understand.

Well, I'm using this for drag&drop.

And therefore it would be nice, if I could change values while they will load, instead of let the entity load and afterwards loop the same fields again for setting the ID to 0 in this example.

My point is, that some associated entities should be also new instances, while others should be linked.

What is the problem with tweaking the entity after it's loaded? Normal, expected and safer way is to deserialize the original entity, and then change whatever properties you want.

All deserialized objects will be new instances, I don't see how you could link to an instance that is located in another process.

Aurelius would link, because deserialized objects will get their IDs, that's where Aurelius starts updating data, instead of inserting, as it should in every other situation.

I could use the current Callback (OnEntityCreate), to set IDs to 0, but I would need the given association, they will be linked to, so that I become able to decide, if ID has to be 0 or not.

That is out of scope of the deserialization. You want to deserialize the entity, set the id to 0 to create a new one. Only you can tell the associations you have in the object tree and which associations should be created or kept.

If there is no problem for you to keep the same id as the original database, then you can use Manager.Replicate. That will do the job for you - if the entity with that specified id doesn't exist in the database, it will create it, otherwise it will update it.

Yeah, replicate would solve this, but at the end the entities will have their IDs, so that datas will only updated.
I need 100% copies of the entities, except unique-keys.
Right now, I'm solving it by looping over Explorer.GetAssociations for each deserialized entity.
Deserializer is looping over them before, that's why I'm asking for an

I don't get it, you have solved your issue, why add complexity and slowness to the serializer/deserializer?

I don't think adding another Event, like OnEntityCreate, that also provides RttiOptimization of the field would make it more complex at all.

But if you would not like to do so, we could close this

We can consider it, can you please file a feature request with more details? That would be an OnObjectCreated event whenever the deserializer creates a new object?