我想序列化数据表中的查询结果
public static IList<DTO.Customer> GetData()
{
using (DBDataContext odb = new DBDataContext())
{
return ConvertDALtoDTO(odb.Customers.ToList());
}
}
public static List<DTO.Customer> ConvertDALtoDTO(List<DAL.Customer> d)
{
try
{
string SerializedObj = JsonConvert.SerializeObject(d,Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
List<DTO.Customer> result = JsonConvert.DeserializeObject<List<DTO.Customer>>(SerializedObj);
return result;
}
catch (Exception ex)
{
return null;
}
}
但是我遇到“内存不足”错误,执行代码后系统内存已满,并显示以下错误 “对象引用未设置为对象的实例”