Set property on Base object as chunkable dynamically


I have a base object that I want to assign some other base objects to. I want to set each one as chunkable. My current logic is:

var b = new Base(); //for example
var objects = new List<Base>(){object1, object2}; //for example

foreach(var o in objects)
  var i = objects.IndexOf(o);
  b[@$"object_{i}"] = o; //I want to add the chunkable attribute each time here

How would I do such a thing without declaring a new type that inherits Base?
I see that you can add a @ prefix for detached attributes, but I am unsure what the prefix is for chunkable attributes…


1 Like

Hey Jack,

The equivalent prefix to dynamically set a property as Chunkable is to follow the @ with the target chunk size in parentheses. e.g. @(2000)Bananas. Alternatively, @()Bananas would apply the default chunking size inside the serializer. You say you don’t want to create an object type inheriting from Base, but that can be the neatest and easiest-to-read way to achieve this. What’s the objection?

Before we get into that, though, the logic you show here doesn’t suggest that chunking is what you want to do.

In your example, each dynamically named property you add to the root Base is assigned a single child Base object. Detaching works here, but that isn’t what Chunking is for. Chunking handles very long Enumerables (List, Array) and slices that list. A Base object isn’t enumerable. Were you to have a property @(10000)Objects on a class that was that list of Base objects, that might be a candidate for Chunking except that it is intended for BIG Lists of simple/built-in types.

I suppose I’d like to know more about what you want to achieve and what you think Chunking would solve for you.


That’s the answer I was after. We have a series of list properties that we want to append to a base object (for example a list of meshes, converted to base). That enumerable we want to chunk up, as it potentially can be very large. @sanchez can provide some more insight, as it’s his problem, but this gave us the answer he was after :smiley: