ravendbweakly-typed

RavenDB: Adding documents from weakly-typed objects


I'm trying to figure out how to insert weakly-typed objects as RavenDB documents.

For example, I would like to insert a Datatable as a document:

Although the data is in a Datatable, it doesn't fit a relational DB, and the proper use would be in a NoSQL DB.
I have a lot of different Datatables with different schemas, and I do not want to create a representing class for each table manually.

Any suggestions?


Solution

  • You can create a dynamic class where each column is a field and then, using reflection, create a new object of the dynamic type and map Row[Col_Name] to obj.Col_Name. After you create the object store it in the session.