You might know LINQ doesn't limit developers from "above" in its implementation: since LINQ allows to use any C#/VB.NET expressions in queries, particular LINQ provider can be as complex as its developer wishes. On the other hand, it would be anyway limited, because normally it is impossible to translate any C# expression to e.g SQL. If so, what do we mean when we're saying one LINQ provider is better than another? By our opinion, the quality of LINQ provider is determined by:
- Supported set of standard LINQ methods (extension methods exposed by Queryable type) and their complex use cases, e.g. usage of a particular LINQ method inside expression passed to another one (something similar to subquery in SQL), usage of lambda parameter defined in parent scope and so on.
- Supported set of operations (==, !=, and so on) and methods of standard .NET types, such as DateTime, TimeSpan, String, Double and so on
- Supported set of frequently used utility methods, such as methods of Math.*
- Supported set of operations and methods of ORM entity types. E.g. ==, != and object.Equals for entities and keys.
- Nullability support.
- Quality of translation. This implies that:
a) translator must produce such a replacement for a particular expression that can't lead to a query plan with unexpectedly high cost. E.g. we think translation of string.StartsWith to CHARINDEX(...)==1 is bad, but translation it to ... LIKE ... is good, because second option allows query optimizer to use index seek instead of index scan, but the first one does not.
b) ideally, produced queries must be human readable, or there must be an option to produce such queries. Although this is less important than everything else.
where c.Orders.Count==0
Its "check" query will be:
where c.Orders.AsEnumerable().Count==0
LINQ test sequence currently consists of 117 tests, but score is measured as percentage of passed tests. Why? Mainly, because this number is quite simple to understand. But what about the above statement that it's impossible to get 100% LINQ implementation? The statement is correct, 100% score here is related just to ORMBattle.NET test sequence.
Finally, it worth to say what are common requirements to all LINQ tests:
- Any test must pass on at least one ORM
- Test sets are selected to test particular features. Each feature is tested using a test set composed of N tests with varying complexity. Each feature test must test (or involve) just a particular feature.
- Multi-feature tests are organized into "Complex" test set.
- Ideally, just few frameworks must pass the most complex test in each set.