In a table, Leads, there is a column Data that contains a JSON string. In a LINQ statement, I need to extract a field from that JSON:
var results = from l in leads
select new MyLeadObject
{
LeadID = l.LeadID,
...
RequestType = (string)l.Data["RequestTypeID"]
};
Here's a shortened version of the JSON:
{
"RequestTypeID":1
}
RequestTypeID is a string.
I've been reading other threads and trying to cobble this together. Not having much luck.
EDIT:
With help from Nkosi, I got this far:
RequestType = (string)JSONNetSerialization.DeserializeJsonNet<LeadData>(l.Data).RequestTypeID
The only problem is that LeadData.RequestTypeID is an enum, so it won't convert the enum to a string. I'm not sure how to get the value of the enum instead of the entire enum itself. Outside of LINQ I could do this: RequestTypeID.GetDisplayName(); but .GetDisplayName() is not recognized by LINQ.
leadsa direct call to the table or is it already in memory