www.db4o.com
ListResult(result);
OUTPUT:
1
BMW[Rubens Barrichello/99]/2
We can also query for the collections themselves, since they are first class objects.
// retrieveCollections
IObjectSet result = db.QueryByExample(new ArrayList());
ListResult(result);
OUTPUT:
2
[]
[BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.1,0.2,0.3,
BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.2,0.4,0.6]
This doesn't work with arrays, though.
// retrieveArrays
IObjectSet result = db.QueryByExample(new double[] { 0.6, 0.4 });
ListResult(result);
OUTPUT:
0
Convert pdf to word and edit text - Convert PDF to txt files in C#.net, ASP.NET MVC, WinForms, WPF application
C# PDF to Text (TXT) Converting Library to Convert PDF to Text
convert pdf to word searchable text; convert pdf to text without losing formatting
Convert pdf to word and edit text - VB.NET PDF Convert to Text SDK: Convert PDF to txt files in vb.net, ASP.NET MVC, WinForms, WPF application
VB.NET Guide and Sample Codes to Convert PDF to Text in .NET Project
convert pdf to text c#; convert pdf into text file
www.db4o.com
6.2.2. Native Queries 
If we want to use Native Queries to find SensorReadouts with matching values, we simply write this as
if we would check every single instance:
public class RetrieveSensorReadoutPredicate : Predicate
{
public bool Match(SensorReadout candidate)
{
return Array.IndexOf(candidate.Values, 0.3) > -1
&& Array.IndexOf(candidate.Values, 0.1) > -1;
}
}
// retrieveSensorReadoutNative
IObjectSet results = db.Query(new RetrieveSensorReadoutPredicate());
ListResult(results);
OUTPUT:
0
And here's how we find Cars with matching readout values:
public class RetrieveCarPredicate : Predicate
{
public bool Match(Car car)
{
foreach (SensorReadout sensor in car.History)
{
if (Array.IndexOf(sensor.Values, 0.3) > -1
VB.NET PDF Convert to Word SDK: Convert PDF to Word library in vb.
VB.NET Tutorial for How to Convert PDF to Word (.docx) Document in VB.NET. using RasterEdge.XDoc.PDF; Convert PDF to Word Document in VB.NET Demo Code.
c# convert pdf to text file; convert pdf into text
C# PDF Convert to Word SDK: Convert PDF to Word library in C#.net
third-party software, you can hardly edit PDF document Under this situation, you need to convert PDF document to some easily editable files like Word document
convert pdf to text; convert pdf to txt format online
www.db4o.com
&& Array.IndexOf(sensor.Values, 0.1) > -1)
{
return true;
}
}
return false;
}
}
// retrieveCarNative
IObjectSet results = db.Query(new RetrieveCarPredicate());
ListResult(results);
OUTPUT:
1
BMW[Rubens Barrichello/99]/2
6.2.3. Query API 
Handling of arrays and collections is analogous to the previous example. First, lets retrieve only the
SensorReadouts with specific values:
// retrieveSensorReadoutQuery
IQuery query = db.Query();
query.Constrain(typeof(SensorReadout));
IQuery valueQuery = query.Descend("_values");
valueQuery.Constrain(0.3);
valueQuery.Constrain(0.1);
IObjectSet results = query.Execute();
ListResult(results);
C# Convert: PDF to Word: How to Convert Adobe PDF to Microsoft
C# Convert: PDF to Word: How to Convert Adobe PDF to Microsoft Word (.docx) File. Empower C# users to easily convert PDF document to Word document.
convert pdf scanned image to text; convert pdf to txt format
VB.NET Create PDF from Word Library to convert docx, doc to PDF in
XDoc.HTML5 Viewer. view, Annotate,Convert documents online using ASPX. XImage.Raster. XDoc.PDF. Scanning. Microsoft Office. XDoc.Word. XDoc.Excel. XDoc.PowerPoint
convert pdf file to text; converting pdf to searchable text format
www.db4o.com
OUTPUT:
1
BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.1,0.2,0.3
Then let's get some Cars with matching Readout values:
// retrieveCarQuery
IQuery query = db.Query();
query.Constrain(typeof(Car));
IQuery historyQuery = query.Descend("_history");
historyQuery.Constrain(typeof(SensorReadout));
IQuery valueQuery = historyQuery.Descend("_values");
valueQuery.Constrain(0.3);
valueQuery.Constrain(0.1);
IObjectSet results = query.Execute();
ListResult(results);
OUTPUT:
1
BMW[Rubens Barrichello/99]/2
6.3. Updating and deleting 
This should be familiar, we just have to remember to take care of the update depth.
// updateCar
IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(Car)).CascadeOnUpdate(true);
IObjectContainer db = Db4oEmbedded.OpenFile(config, YapFileName);
C# Create PDF from Word Library to convert docx, doc to PDF in C#.
A convenient C#.NET control able to turn all Word text and image content into high quality PDF without losing formatting. Convert multiple pages Word to
convert scanned pdf to text online; convert pdf to text vb
C# PDF Text Extract Library: extract text content from PDF file in
source PDF document file for word processing, presentation extract text content from source PDF document file obtain text information and edit PDF text content
convert pdf to .txt file; converting pdf to editable text for
www.db4o.com
IObjectSet result = db.QueryByExample(new Car("BMW", null));
Car car = (Car)result.Next();
car.Snapshot();
db.Store(car);
RetrieveAllSensorReadout(db);
db.Close();
OUTPUT:
3
BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.1,0.2,0.3
BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.2,0.4,0.6
Ferrari[Michael Schumacher/100]/1 : 1244836444389 : 0.1,0.2,0.3
There's nothing special about deleting arrays and collections, too.
Deleting an object from a collection is an update, too, of course.
// updateCollection
IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(Car)).CascadeOnUpdate(true);
IObjectContainer db = Db4oEmbedded.OpenFile(config, YapFileName);
IQuery query = db.Query();
query.Constrain(typeof(Car));
IObjectSet result = query.Descend("_history").Execute();
IList history = (IList)result.Next();
history.RemoveAt(0);
db.Store(history);
Car proto = new Car(null, null);
result = db.QueryByExample(proto);
foreach (Car car in result)
{   
foreach (object readout in car.History)
{
Console.WriteLine(readout);
}
C# PDF Convert to HTML SDK: Convert PDF to html files in C#.net
easy for C# developers to convert and transform style that are included in target PDF document file original formatting and interrelation of text and graphical
convert pdf file to text online; convert pdf to openoffice text
VB.NET PDF Convert to Jpeg SDK: Convert PDF to JPEG images in vb.
C#.NET convert csv to PDF, C#.NET convert PDF to svg, C#.NET convert PDF to text, C#.NET convert PDF to images VB.NET How-to, VB.NET PDF, VB.NET Word, VB.NET
convert pdf to text open source; convert pdf to word to edit text online
www.db4o.com
}
db.Close();
OUTPUT:
BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.1,0.2,0.3
BMW[Rubens Barrichello/99]/2 : 1244836444014 : 0.2,0.4,0.6
(This example also shows that with db4o it is quite easy to access object internals we were never
meant to see. Please keep this always in mind and be careful.)
We will delete all cars from the database again to prepare for the next chapter.
// deleteAll
IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(Car)).CascadeOnDelete(true);
IObjectContainer db = Db4oEmbedded.OpenFile(config, YapFileName);
IObjectSet result = db.QueryByExample(new Car(null, null));
foreach (object car in result)
{
db.Delete(car);
}
IObjectSet readouts = db.QueryByExample(new SensorReadout(null,
DateTime.MinValue, null));
foreach (object readout in readouts)
{
db.Delete(readout);
}
db.Close();
6.4. Conclusion 
Ok, collections are just objects. But why did we have to specify the concrete ArrayList type all the way?
www.db4o.com
Was that necessary? How does db4o handle inheritance? We will cover that in the next chapter.
6.5. Full source 
using System;
using System.Collections;
using System.IO;
using Db4objects.Db4o;
using Db4objects.Db4o.Config;
using Db4objects.Db4o.Query;
namespace Db4odoc.Tutorial.F1.Chapter4
{   
public class CollectionsExample : Util
{
readonly static string YapFileName = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationD
ata),
"formula1.yap"); 
public static void Main(string[] args)
{
File.Delete(YapFileName);
IObjectContainer db =
Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), YapFileName);
StoreFirstCar(db);
StoreSecondCar(db);
RetrieveAllSensorReadout(db);
RetrieveSensorReadoutQBE(db);
RetrieveCarQBE(db);
RetrieveCollections(db);
RetrieveArrays(db);
RetrieveSensorReadoutQuery(db);
RetrieveCarQuery(db);
db.Close();
UpdateCar();
UpdateCollection();
DeleteAll();
www.db4o.com
RetrieveAllSensorReadout(db);
}
public static void StoreFirstCar(IObjectContainer db)
{
Car car1 = new Car("Ferrari");
Pilot pilot1 = new Pilot("Michael Schumacher", 100);
car1.Pilot = pilot1;
db.Store(car1);
}
public static void StoreSecondCar(IObjectContainer db)
{
Pilot pilot2 = new Pilot("Rubens Barrichello", 99);
Car car2 = new Car("BMW");
car2.Pilot = pilot2;
car2.Snapshot();
car2.Snapshot();
db.Store(car2);      
}
public static void RetrieveAllSensorReadout(IObjectContainer
db)
{
IObjectSet result =
db.QueryByExample(typeof(SensorReadout));
ListResult(result);
}
public static void RetrieveSensorReadoutQBE(IObjectContainer
db)
{
SensorReadout proto = new SensorReadout(new double[] {
0.3, 0.1 }, DateTime.MinValue, null);
IObjectSet result = db.QueryByExample(proto);
ListResult(result);
}
public static void RetrieveCarQBE(IObjectContainer db)
{
www.db4o.com
SensorReadout protoReadout = new SensorReadout(new
double[] { 0.6, 0.2 }, DateTime.MinValue, null);
IList protoHistory = new ArrayList();
protoHistory.Add(protoReadout);
Car protoCar = new Car(null, protoHistory);
IObjectSet result = db.QueryByExample(protoCar);
ListResult(result);
}
public static void RetrieveCollections(IObjectContainer db)
{
IObjectSet result = db.QueryByExample(new ArrayList());
ListResult(result);
}
public static void RetrieveArrays(IObjectContainer db)
{
IObjectSet result = db.QueryByExample(new double[] { 0.6,
0.4 });
ListResult(result);
}
public static void
RetrieveSensorReadoutQuery(IObjectContainer db)
{
IQuery query = db.Query();
query.Constrain(typeof(SensorReadout));
IQuery valueQuery = query.Descend("_values");
valueQuery.Constrain(0.3);
valueQuery.Constrain(0.1);
IObjectSet results = query.Execute();
ListResult(results);
}
public static void RetrieveCarQuery(IObjectContainer db)
{
IQuery query = db.Query();
query.Constrain(typeof(Car));
IQuery historyQuery = query.Descend("_history");
historyQuery.Constrain(typeof(SensorReadout));
IQuery valueQuery = historyQuery.Descend("_values");
www.db4o.com
valueQuery.Constrain(0.3);
valueQuery.Constrain(0.1);
IObjectSet results = query.Execute();
ListResult(results);
}
public class RetrieveSensorReadoutPredicate : Predicate
{
public bool Match(SensorReadout candidate)
{
return Array.IndexOf(candidate.Values, 0.3) > -1
&& Array.IndexOf(candidate.Values, 0.1) > -1;
}
}
public static void
RetrieveSensorReadoutNative(IObjectContainer db)
{
IObjectSet results = db.Query(new
RetrieveSensorReadoutPredicate());
ListResult(results);
}
public class RetrieveCarPredicate : Predicate
{
public bool Match(Car car)
{
foreach (SensorReadout sensor in car.History)
{
if (Array.IndexOf(sensor.Values, 0.3) > -1
&& Array.IndexOf(sensor.Values, 0.1) > -1)
{
return true;
}
}
return false;
}
}
public static void RetrieveCarNative(IObjectContainer db)
{
Documents you may be interested
Documents you may be interested