在 C# 或 VB.NET 中将 Linq to SQL 结果序列化为 JSON (newtonsoft)

Serialize Linq to SQL result into JSON (newtonsoft) in C# or VB.NET

我有一个简单明了的 Linq to SQL 查询:

dim result = from c in ctx.customers select c

如何使用 Newtonsoft.JSON 使用 VB.NET(最好)或 c# 序列化结果?

因为我作为一个程序员很懒惰,所以我不想为结果创建一个 class,因为会有很多不同的查询(是的,给我投反对票......让我开心 :- )

尝试使用 JsonConvert.SerializeObject

dim json = JsonConvert.SerializeObject(result)