tags:

views:

61

answers:

1

Hi All,

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);

I think the problem is on the line p.RSSFeeds, RSSFeeds here is a list of RSSFeed objects. I want to select only Description and RSSFeedID fields of this list -foreach object RSSFeed object- how can i do that?

Thanks...

A: 

problem solved.

p.RSSFeeds.Select(x => new {x.Description,x.RSSFeedID}),
mehmet6parmak