7

Is it possible to store an ESRI object inside a blob field inside a geodatabase? If not, perhaps a serialized XML representation?

I'm thinking about storing IFeatureRenderers inside these fields.

Any tips? Anyone has ever done this?

9

Yes, essentially that is what the Store and retrieve Layers in the GeoDatabase sample does. Haven't seen a .NET port of this though.

In general, as long as the object implements IPersistStream or IPersistVariant, then it can be persisted to a blob in a database.

  • I did not know that sample. I'll take a look into it Kirk. Blobs may be better than XML in my opinion. Thanks for the help. looks fairly easy too! – George Silva Apr 12 '11 at 18:46
  • 1
    Forgot to mention the tip: if putting an abstract class in a blob, put it in a propertyset first. Otherwise the deserialization process needs to know what the progid is. This would apply to IFeatureRenderer as well as ILayer instances. – Kirk Kuykendall Apr 13 '11 at 14:58
2

Yes, you can safely persist feature renderers to a blob. In fact, I did exactly that in one of my past projects.

Would probably not work easily for XML since there might be objects in the object graph which do not support XML serialization.

  • this is a important comment. I will definetely go the blob route. It's even better because I can save a whole bunch of other information, such as labelling information. – George Silva Apr 12 '11 at 19:03
1

Many objects that do not implement IXmlSerialize can still be serialized to XML. Those objects will simply contain a Base64-encoded string of the binary serialization. Not really efficient or ideal, but useful if you have a need for some objects to be persisted to a human readable.

1

The IServerContext has a SaveObject and LoadObject method. This lets you save arcObjects as a string and then load it back up when you want it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.