Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1027881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:18:05+00:00 2026-05-16T12:18:05+00:00

I want to change all objects that match a condition to use a specific/new

  • 0

I want to change all objects that match a condition to use a specific/new subclass.

There are no other subclasses being used with the stored objects, so its in all cases a change from the base class to its subclass.

In order to keep all references pointing to these objects, I tried using bind to replace them with new instances of the subclass (copying all the data), but it seems bind its restricted only to items of the same specific class.

Is there any way to do this that doesn’t require adding code to explicitly update every reference that points to these objects? A single call that replaces all references from one object to another would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:18:06+00:00Added an answer on May 16, 2026 at 12:18 pm

    Good question. As far as I know this isn’t possible =(. The only way is to copy the data over to the new type.

    As you said, when you copy the data over to the new type, you have the issue that there are lots of references which point to the old instance instead of the new instance. And bind indeed checks the type.

    This leaves no option but coping and updating all references, which is of course a tedious process. =( So query for all object you need to change the type. Copy the data to the new object. Then query for all object which reference to the old object and replace the reference.

    IObjectContainer container = ... //
    foreach(var oldObject in container.Query<MyType>())
    {
         NewSubType newCopy = copyToSubType(oldObject); // copy the data
    
         var referencesFromTypeA = from TypeA a in container
                                   where a.ReferenceToMyType == oldObject
                                   select a
         // repeat this for all types which can refer to the object which are copied
         // it can certainly be generified
         foreach(var referenceToUpdate in referencesFromTypeA)
         {
                referenceToUpdate.ReferenceToMyType=newCopy;
                container.Store(referenceToUpdate);
         }
         container.Store(newCopy);
         container.Delete(oldObject);
    }
    

    Don’t forget to replace the referenced in collections and array.

    Btw. I think I’ve some code around which analyses the types and finds properties which refer to another type and find the object for it. If it helps?

    Now to another potential way to do it, if your up for adventures: Change the db4o code a little. Because you want to change the objects to a subtype, it should be safe to ‘Bind’ it to the new object. So if the existing object suddenly point to the new subtype, it still should work. So what you could do it to remove the check in the Bind-Method-implementation and try to run it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I want to change a value for all objects in an array. I
I'm new to computer vision, and I want to detect specific and flat objects
Let's say I want to write a regular expression to change all <abc> ,
All I want is to be able to change the color of a bullet
I created my own class that I want Core Data to use instead of
I'm trying to change a specific field from a field in an object that
I want to use a temp directory that will be unique to this build.
I'm trying to create a class to use as a field in other objects
I want to override the behaviour of objects.all() of a particular model based on
I want to register to get notified of all Java changes in Eclipse. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.