In this post I'm going to show you all the different types of queries you can perform with LinqToLfsWorld. For an overview of what the library is and how it works, please feel free to read an earlier blog post which takes you through the demo website (included with the library download file).
The Queries
With the library you can perform all the queries that you would
normally be able to using a plain url to LfsWorld (according to v1.4 of
the pubstat service, which is the latest version at the time of
release). These queries are accessed through the LfsWorldContext. All
the examples below assume I have already initialised my context with
the name lfswContext, and called Dispose() when I've finished
with it. Disposing the context is important so that it can free up
memory and unregister internal event handlers. If you don't dispose the
context, you might find some weird things happening if you've handled
the context's RequestMade event.

Racer Stats
Required parameters: RacerName
var query = from stat in lfswContext.RacerStats
where stat.RacerName == "elkdanger"
select stat;
This query will either return no results or one result; LinqToLfsWorld supports the use of the Single and SingleOrDefault methods, so retrieving a single entity instance is quite easy.
Racer Fuel
Required parameters: RacerName
var query = from fuelInfo in lfswContext.RacerFuels
where fuelInfo.RacerName == "elkdanger"
select fuelInfo;
This query returns information about the fuel usage of a racer, on a given track in a given car.
Personal Bests
Required parameters: RacerName
var query = from pb in lfswContext.PersonalBests
where pb.RacerName == "elkdanger"
select pb;
World Records
Required Parameters: None
Optional parameters: Car, TrackIdent
var query = from wr in lfswContext.WorldRecords
where wr.Car == "XRG"
&& wr.TrackIdent == "000"
select wr;
The values for TrackIdent and Car are exactly the same
as the pubstat service normally accepts, according to the pubstat documentation on lfsworld.net.
Hotlaps
Required parameters: RacerName
var query = from hl in lfswContext.Hotlaps
where hl.RacerName == "elkdanger"
select hl;
Hotlap Chart
Required parameters: TrackIdent, Car
Optional parameters: SteeringMethod
var query = from hlc in lfswContext.HotlapChart
where hlc.TrackIdent == "000"
&& hlc.Car == "XRG"
&& hlc.SteeringMethod == "ms"
select hlc;
The values for TrackIdent, Car and SteeringMethod are exactly the
same as the pubstat service normally accepts, according to the pubstat documentation on lfsworld.net.
Hotlap Log
Required parameters: None
Optional parameters: Steering, LogFilter, StartTime, Lines
var query = from hll in lfswContext.HotlapLog
where hll.Steering == "ms"
&& hll.LogFilter == HotlapLogFilter.Top10
&& hll.StartTime == DateTime.Now.AddMonths(-1).ToUnixTimestamp();
&& hll.Lines == 90
select hll;
It's worth mentioning here the call to ToUnixTimestamp(). By importing the LinqToLfsWorld.Extensions
namespace. As the name suggests, this method is an extension on the
.Net DateTime object which translates it into a unix timestamp value.
Similarly, by calling DateTimeExtensions.FromUnixTimestamp(timestamp) you can convert a timestamp value into a DateTime object; again after importing the LinqToLfsWorld.Extensions namespace.
Hosts
Required parameters: None
var query = from host in lfswContext.Hosts select host;
Teams
Required parameters: None
var query = from team in lfswContext.Teams select team;
That is all the queries that can be performed with the
LinqToLfsWorld library. Of course all of these queries can be made
using the normal method syntax, such as in:
var query = lfswContext.RacerStats
.Where(stats => stats.RacerName == "elkdanger").Single();
And of course, such is the nature of Linq, all these queries are
only ever executed on the server when the results are enumerated.