As Lasse says, that is a vague question, but there are some definite
advantages that can be pointed to.
The biggest one is that you can now structure queries in your code which
are compile-time checked, regardless of the back end data source (so if you
are using LINQ-to-SQL, then you are going to get compile-time checking on
your queries, instead of seeing it at runtime with a query string).
If you are using LINQ-to-Objects, then a big advantage is that you can
create complex queries in a simple manner which were previously very
difficult.
For example, say you want to get all the declared methods on a type
which are generic which you want to run some processing on. In .NET 2.0,
you would do this:
// Get the methods. Assume type is of type Type.
IEnumerable<MethodInfo> methods = type.GetMethods();
// Cycle.
foreach (MethodInfo methodInfo in methods)
{
// Check to see if the method is generic.
if (methodInfo.IsGeneric)
{
// Continue processing.
}
}
In .NET 3.5/C# 3.0, you can do this:
// Generate the query.
IEnumerable<MethodInfo> methods =
from methodInfo in type.GetMethods()
where methodInfo.IsGeneric
select methodInfo;
// Process the methods.
foreach (MethodInfo methodInfo in methods)
{
// Process.
}
Subsequently, you could also do this, which is even simpler, in my
opinion:
// Get the methods.
IEnumerable<MethodInfo> methods = type.GetMethods().Where(methodInfo =>
methodInfo.IsGeneric);
// Process.
foreach (MethodInfo methodInfo in methods)
{
// Process.
}
Two big wins, IMO.