Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Wednesday, April 09, 2014

Reading json easily with C#

You need Newtonsoft.Json dll and use of "dynamic" type in C# to do below.
This code gets follower count from Twitter api without the need to create extra classes
to load json data  : 
 
var wc = new WebClient(); 
string json= wc.DownloadString(url);

         dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(json); 
        int? twFollowerCount =obj.followers_count;

Tuesday, August 13, 2013

EF , how to query result of query again

           var schools = entities.Companies.OfType<School>();
                if (hasHSAlumni)
                {
                    schools = (ObjectQuery<School>)schools.Where(p => p.HSGraduateExist == true);
                }

Monday, July 08, 2013

where in clause with Lambda expression

List<int> eventTypeIDs
 
   var ets =  entities.EventTypes.Where(p => eventTypeIDs.Contains(p.ID));