I m developing a web application myself to follow some rssfeeds. My purpose is just learning some ajax and i send data from server to client side in JSON format. I use LINQ for querying data and JSON .NET API for object to string Serialization in the server side. The problem is that because of there exists foreign keys between my tables linq objects include references to the same table and JSON .NET API throws self referencing object error.
DAL.BlogReaderDBDataContext db = new DAL.BlogReaderDBDataContext();
var list = from p in db.Lookup_RSSFeedCategories
select new
{
CreateDate = p.CreateDate.ToLongDateString(),
p.Description,
p.RSSFeeds,
p.RSSFeedCategoryId
};
return Newtonsoft.Json.JsonConvert.SerializeObject(list);
我认为,这个问题在p.RSSFeeds上,这里的RSSFeeds是RSSFeed物体清单。 我只想选择这份名单的描述和RSSFeedID领域——每个物体SSFeed物体——如何做到这一点?
谢谢... (xiè xiè...)