The return type of Query<TEntity> – and therefore of any wrapper methods – is IQueryable<TEntity>. This means that, in addition to the language-specific LINQ syntax, you can use any of the standard query operators, such as Any, Count or Sum. See the Queryable class in the .NET Framework SDK for a full list. (Note that some operators, such as Aggregate or SkipWhile, cannot be translated into LightSpeed queries and these will cause a runtime error.) For example:

1var query = from t in UnitOfWork.Tags 2 select t.Usages; 3 4int mostUsedTag = query.Max();

1var prolificContributors = from m in UnitOfWork.Members 2 where m.Contributions.Count() > 8 3 select m;
LINQ is the primary interface to join and grouping support. Although joins and groups can be written using the core query API, they are generally easier to write using LINQ. For example:

1var q = 2 from m in UnitOfWork.Members 3 join c in UnitOfWork.Contributions on m.Id equals c.ContributorId 4 select new { Member = m, Contribution = c };

1var nameGroups = 2 from c in UnitOfWork.Contacts 3 group c by c.FullName[0] into g 4 select new { FirstLetter = g.Key, Names = g };
LINQ to LightSpeed also allows you to write queries using familiar .NET methods and your preferred language’s operator syntax, and have them automatically translated into appropriate SQL. For example:

1var query = from m in UnitOfWork.Members 2 where m.UserName.StartsWith("j") 3 select m;

1var query = from t in UnitOfWork.Tags 2 orderby t.Id 3 select t.Usages + t.Id;
LINQ to LightSpeed supports projections through the normal LINQ selection syntax:

1var titles = from contribution in UnitOfWork.Contributions 2 where contribution.Id == 1 3 select contribution.Title;

1var idsAndTitles = from contribution in UnitOfWork.Contributions 2 where contribution.Id == 1 3 select new { Ident = contribution.Id, Name = contribution.Title };
In both of these cases, the operation runs efficiently in the database—the methods run on the server, and only the required fields are selected, not the entire entity. (Note: for certain complex projections, it may be necessary for LightSpeed to select the entire entity and perform the projection on the client, which is less efficient.)
Refer to the “LINQ Queries” sample for further examples of LINQ usage and patterns.