0
votes

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:

  • Each row is mapped to a single document
  • The columns are mapped keys in the document
  • The entire Datatable is a collection of documents of the same schema

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?

2

2 Answers

2
votes

KellyG, You can do that using a format such as this:

public class Item
{
    public Dictionary<string, Item> Children {get;set;}

}

That would serialize cleanly into RavenDB, and you can then query / load / modify things easily

0
votes

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.