user3553401
user3553401

Reputation: 109

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

I have a plain and simple Linq to SQL query:

dim result = from c in ctx.customers select c

How can I use Newtonsoft.JSON to serialize the result using VB.NET (preferably) or c#?

As I'm lazy as a programmer, I don't want to create a class for the result because there will be many different queries (yes, downvote me... Make my day :-)

Upvotes: 1

Views: 1706

Answers (1)

Zasz
Zasz

Reputation: 12538

Try using JsonConvert.SerializeObject

dim json = JsonConvert.SerializeObject(result)

Upvotes: 2

Related Questions