Those of you who are familiar with db4o query processor may already suspect that LINQ queries as well as NQ and QueryByExample queries are converted to SODA Query under the hood. And that is true. The downside of this is that some of the queries cannot be converted to SODA and will run against all instances of matching class objects. Some of the cases when conversion is not possible:
01private static void SelectUnoptimized() 02
{ 03
IObjectContainer container = Database(); 04
if (container != null) 05
{ 06
try 07
{ 08
IEnumerable<Pilot> result = from Pilot p in container 09
where p.Points == p.Name.Length 10
select p; 11
12
ListResult(result); 13
} 14
catch (Exception ex) 15
{ 16
System.Console.WriteLine("System Exception: " + ex.Message); 17
} 18
finally 19
{ 20
CloseDatabase(); 21
} 22
} 23
}
01Private Shared Sub SelectUnoptimized() 02
Dim container As IObjectContainer = Database() 03
If container IsNot Nothing Then 04
Try 05
Dim pilots = From item In container _ 06
Where item.GetType Is GetType(Pilot) Select CType(item, Pilot) 07
Dim result As IEnumerable(Of Pilot) = From p _ 08
In pilots Where p.Points = p.Name.Length Select p 09
ListResult(result) 10
Finally 11
CloseDatabase() 12
End Try 13
End If 14
End Sub