Multiple emits in Map functions in couchbase lite - C#

Hi all ,

How can i emit multiple values in the map function . Below is the sample

i want to emit “firstName, lastName,phoneNo,emailID, roles, userID, userImageUrl, userPassword, userName” values which are present in a JSON document with some other properties , having emailID as my key . what will the map function look like in c# :

I have written the below emit , but the compiler is throwing error . Please help

emit(doc[“emailID”],[ doc[“firstName”], doc[“lastName”], doc[“phoneNo”], doc[“roles”], doc[“userID”], doc[“userImageUrl”], doc[“userPassword”], doc[“userName”]] );

You have two choices. Either emit the key multiple times (one for each value you want) or make the value be an array.

Multiple values, not keys, right? Just make the value you pass to emit an array or a dictionary/map. I don’t know the proper C# syntax for that.

Ok now i have put all the values in a dictionary as below and emit the dictionary

                Dictionary<int , object> obj = new Dictionary<int , object>();
                obj.Add(1, doc["firstName"]);
                obj.Add(2, doc["lastName"]);
                obj.Add(3, doc["phoneNo"]);
                obj.Add(4, doc["roles"]);
                obj.Add(5, doc["userID"]);
                obj.Add(6, doc["userImageUrl"]);
                obj.Add(7, doc["userPassword"]);
                obj.Add(8, doc["userName"]);

                emit(doc["emailID"],obj );

But when i query the view as below , how can i get all the above values from obj (which is a value emitted ). I have written the query as below

        var query = db.GetView("Sites").CreateQuery();
        query.Descending = true;
        //query.Limit = 3;

            var results = query.Run();
            foreach (var result in results)
                Dictionary<int, object> doc = new Dictionary<int, object>();
                var emailID = result.Key;
                var doc = result.Value;


If i use doc as above i get a compiler error saying to cast the result.Value
when i cast the result.Value to dictionary object no compiler errors , but i get a run time exception
if i use a simple variable like var doc1 = result.value , how will i be able to get all the elements in the dictionary.