oslofjord / sanity-linq

Strongly-typed .Net Client for Sanity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to work with Block Containers of multiple types?

piotr-szczygiel opened this issue · comments

Hi there,

I see that in Table example (https://github.com/oslofjord/sanity-linq/blob/master/demo/Sanity.Linq.Demo/Model/Table.cs) you used Row as SanityObject. Any ideas how to structure the data in case when I have ContentArea property (instead of Table) that contains different types (RichText, Video, Image), not only one?

Hi!
Sanity Linq uses JSON.Net for deserialization. One solution might be to use the JObject or JArray type in your model. That way you could inspect the type of each element and use JSON.Net to convert each element to the correct type after retreiving the result from Sanity.

Thanks, it worked perfectly :)