I've got the following collections:
Table1 = { _id, Title }
Table2 = { _id, Name }
Table3 = { _id, TableType, TableId }
I need to do a query to return a result that includes the Title or Name value from either Table1 or Table2 based on the "TableType" and "TableId" defined in Table3.
So, if I had the following data:
Table1 = {"_id":ObjectId("1"), "Title":"Title1"}
Table2 = {"_id":ObjectId("2"), "Name":"Name1"}
Table3 = {"_id":ObjectId("3"), "TableType":"Table1", "TableId":ObjectId("1")}, {"_id":ObjectId("4"), "TableType":"Table2", "TableId":ObjectId("2")}
The results should be:
Results = {"_id":ObjectId("3"), "TableId":ObjectId("1"), "Value":"Title1"},{"_id":ObjectId("4"), "TableId":ObjectId("2"), "Value":"Name1"}
Any example code on how to pull this off with the latest C# driver would be greatly appreciated. Please don't suggest that my data structure is wrong. I need it this way for a specific reason.