public class RootObject1
{
public Dictionary<string, string> nodeHierarchy { get; set; }
public Dictionary<string, string> Parentnode { get; set; }
public string wsId { get; set; }
public DateTime dateFrom { get; set; }
public DateTime dateTo { get; set; }
public bool IsLeafNode { get; set; }
public decimal weightage { get; set; }
}
/**
* this is what i have in mongodb
* Paste one or more documents here
*/
{
"Parentnode": {
"LEVEL1": "Civil and Structural",
"LEVEL2": "Cluster 1",
"LEVEL3": "Workshop & Maintenance Building"
},
"nodeHierarchy": {
"LEVEL1": "Civil and Structural",
"LEVEL2": "Cluster 1",
"LEVEL3": "Workshop & Maintenance Building",
"LEVEL4": "Excavation"
},
"weightage": "20",
"dateFrom": "2019-01-01",
"dateTo": "2019-12-31",
"IsLeafNode": true,
"wsId": "PROJECT2"
}
List<Models.RootObject1> bsonPlanData2 = collection.AsQueryable().Where(e1 => e1.wsId == WSId).Select(e => new { e.nodeHierarchy, e.Parentnode,e.wsId,e.dateFrom,e.dateTo,e.IsLeafNode,e.weightage }).ToList();
List<Models.RootObject1> bsonPlanData2 = collection.AsQueryable().Where(e1 => e1.wsId == WSId).Select(e => new { e.nodeHierarchy, e.Parentnode,e.wsId,e.dateFrom,e.dateTo,e.IsLeafNode,e.weightage }).ToList();
List<Models.RootObject1> bsonPlanData2 = collection.AsQueryable().Where(e1 => e1.wsId == WSId).Select(e => { e.nodeHierarchy, e.Parentnode,e.wsId,e.dateFrom,e.dateTo,e.IsLeafNode,e.weightage }).ToList();
List<Models.RootObject1> bsonPlanData2 = collection.AsQueryable().Where(e1 => e1.wsId == WSId).Select(e => new RootObject1() { e.nodeHierarchy, e.Parentnode,e.wsId,e.dateFrom,e.dateTo,e.IsLeafNode,e.weightage }).ToList();
above 4 ways are there, where i tried to get the data from mongo and put it in my c# object.
though there is one newtonsoft deserializer is there , but somebody told me that my 4 call also deserializes, so i do not want to use extra conversion by usng newtornsoft desrilizer.
and above code shows me that u have to implemnt ienumerator in my class. so pls tel me is there any othe way i could do this with out implimenting ienumertoe in my class.