We currently have a caching implementation for our service methods that caches the response object. Everything is working as intended except for when the response object contains a property of the type collection (List, IEnumerable, etc.) and we receive the following unserialized output (participants property):
{
"DateStart": "2016-10-03T00:00:00.0000000-07:00",
"DateStarted": null,
"DateEnd": null,
"DateEnded": null,
"ProjectId": null,
"Creator": {
"UserId": 1,
"FirstName": "Test",
"MiddleName": null,
"LastName": "Name",
"Picture": null,
"Initials": "TN"
},
"Participants": "[{__type:Namespace.RedactedResponse, Namespace.Redacted,UserId:1,FirstName:Sample,MiddleName:null,LastName:User,Picture:null,Initials:SU,IsAdministrator:True}]"
}
No matter what we do, we’re unable to solve this issue. Here’s our current caching implementation:
public virtual object TryGetCache<T>(Module module, object cacheKey, TimeSpan? expiration, Func<T> factory)
where T : class
{
if (cacheKey == null)
cacheKey = new Guid();
var compositeKey = string.Concat(module, ":", cacheKey.ToString());
if (expiration == null)
expiration = new TimeSpan(0, 12, 0, 0);
var cacheResult = Cache.Get<T>(compositeKey);
if (cacheResult != null)
return cacheResult;
var result = factory();
if (result == null)
return null;
Cache.Set(compositeKey, result, expiration);
return result;
}
In our AppHost, we have the following properties set for JsConfig:
JsConfig.EmitCamelCaseNames = false;
JsConfig.IncludeNullValues = true;
JsConfig.ExcludeTypeInfo = true;
Any suggestions? Thanks!