What are Lambda Expressions?
Lambda Expressions provide a more concise, functional syntax for writing anonymous methods. They end up being super useful when writing LINQ query expressions - since they provide a very compact and type-safe way to write functions that can be passed as arguments for subsequent evaluation.
The easiest way to conceptualize Lambda expressions is to think of them as ways to write concise inline methods. For example, the sample I wrote above could have been written instead using C# 2.0 anonymous methods like so:
![]()
Both anonymous methods above take a Person type as a parameter. The first anonymous method returns a boolean (indicating whether the Person's lastname is Guthrie). The second anonymous method returns an integer (returning the person's age). The lambda expressions we used earlier work the same - both expressions take a Person type as a parameter. The first lambda returns a boolean, the second lambda returns an integer.
In C# a lambda expression is syntactically written as a parameter list, followed by a => token, and then followed by the expression or statement block to execute when the expression is invoked:
params => expression
So when we wrote the lambda expression:
p => p.LastName == "Guthrie"
we were indicating that the Lambda we were defining took a parameter "p", and that the expression of code to run returns whether the p.LastName value equals "Guthrie". The fact that we named the parameter "p" is irrelevant - I could just have easily named it "o", "x", "foo" or any other name I wanted.
Unlike anonymous methods, which require parameter type declarations to be explicitly stated, Lambda expressions permit parameter types to be omitted and instead allow them to be inferred based on the usage. For example, when I wrote the lambda expression p=>p.LastName == "Guthrie", the compiler inferred that the p parameter was of type Person because the "Where" extension method was working on a generic List<Person> collection.
Lambda parameter types can be inferred at both compile-time and by the Visual Studio's intellisense engine (meaning you get full intellisense and compile-time checking when writing lambdas). For example, note when I type "p." below how Visual Studio "Orcas" provides intellisense completion because it knows "p" is of type "Person":
![]()
Note: if you want to explicitly declare the type of a parameter to a Lambda expression, you can do so by declaring the parameter type before the parameter name in the Lambda params list like so:
Facebook Graph API - The Future Of Semantic Web?
The new Graph API attempts to drastically simplify the way developers read and write data to Facebook. It presents a simple, consistent view of the Facebook social graph, uniformly representing objects in the graph (e.g., people, photos, events, and fan pages) and the connections between them (e.g., friend relationships, shared content, and photo tags).
Every object in the social graph has a unique ID. You can fetch the data associated with an object by fetching
https://graph.facebook.com/ID. For example, the official page for the Facebook Platform has id 19292868552, so you can fetch the object at https://graph.facebook.com/19292868552:{ "name": "Facebook Platform", "type": "page", "website": "http://developers.facebook.com", "username": "platform", "founded": "May 2007", "company_overview": "Facebook Platform enables anyone to build...", "mission": "To make the web more open and social.", "products": "Facebook Application Programming Interface (API)...", "fan_count": 449921, "id": 19292868552, "category": "Technology" }Alternatively, people and pages with usernames can be fetched using their username as an ID. Since "platform" is the username for the page above, https://graph.facebook.com/platform will return what you expect. All responses are JSON objects.
All objects in Facebook can be accessed in the same way:
- Users: https://graph.facebook.com/btaylor (Bret Taylor)
- Pages: https://graph.facebook.com/cocacola (Coca-Cola page)
- Events: https://graph.facebook.com/251906384206 (Facebook Developer Garage Austin)
- Groups: https://graph.facebook.com/2204501798 (Emacs users group)
- Applications: https://graph.facebook.com/2439131959 (the Graffiti app)
- Status messages: https://graph.facebook.com/367501354973 (A status message from Bret)
- Photos: https://graph.facebook.com/98423808305 (A photo from the Coca-Cola page)
- Photo albums: https://graph.facebook.com/99394368305 (Coca-Cola's wall photos)
- Videos: https://graph.facebook.com/614004947048 (A Facebook tech talk on Tornado)
- Notes: https://graph.facebook.com/122788341354 (Note announcing Facebook for iPhone 3.0)
All of the objects in the Facebook social graph are connected to each other via relationships. Bret Taylor is a fan of the Coca-Cola page, and Bret Taylor and Arjun Banker are friends. We call those relationships connections in our API. You can examine the connections between objects using the URL structure
https://graph.facebook.com/ID/CONNECTION_TYPE. The connections supported for people and pages include:
- Friends: https://graph.facebook.com/me/friends
- News feed: https://graph.facebook.com/me/home
- Profile feed (Wall): https://graph.facebook.com/me/feed
- Likes: https://graph.facebook.com/me/likes
- Movies: https://graph.facebook.com/me/movies
- Books: https://graph.facebook.com/me/books
- Notes: https://graph.facebook.com/me/notes
- Photos: https://graph.facebook.com/me/photos
- Videos: https://graph.facebook.com/me/videos
- Events: https://graph.facebook.com/me/events
- Groups: https://graph.facebook.com/me/groups
We support different connection types for different objects. For example, you can get the list of all the people attending the Facebook Developer Garage at SXSW (ID #331218348435) by fetching https://graph.facebook.com/331218348435/attending.
All of the different types of objects and connections we support are included in the Graph API reference documentation.
Contents
The Web is moving to a model based on the connections between people and all the things they care about. This is the future of the online world we live in.







