C# .NET: Turn Object List Into JSON String to Return to Client

12/19/2012 12:16:53 AM

Starting with a list of objects, turn that list into a list of only specific object properties.

//linq to ajax
var query = (from imgs in images                    
			select new
			{
				Id = imgs.Id,
				Title = imgs.Title
			});

return Json(query.ToList(), JsonRequestBehavior.AllowGet);