I'm getting this "Could not evaluate expression" serialization output when I try to serialize a big list. Is there any way to prevent this behaviour?
The worst part is that there is no common exception thrown. If the list is too big, instead of getting an exception to warn me, I just get the mentioned expression instead of my wanted json formatted list.
Note: in case it helps, I'm running my tests with a simple poco entity that looks like this:
public class SomeEntity
{
public int Id {get;set;}
public string Name {get;set;}
public DateTime SomeDate {get;set;}
public bool IsTrue {get;set;}
public short SomeNumber {get;set;}
}
And the lines of code that fail are like this:
var list = new List<SomeEntity>();
LoadHugeAmmountsOfItemsIntoList(list); // this gets me several thousands of items into the list
var serializedList = JsonConvert.SerializeObject(list); // The error appears when I have somewhere between 125k and 150k items or more in the list