Db4o released version 7.2 and. Net version 3.5, supporting

Source: Internet
Author: User

Db4object has just released the 7.2 beta version of db4o. In addition to the previous support for the following platforms:. NET 1.1,. NET 2.0, and mono, it now supports. Net 3.5. Of course. Net 3.5 is supported, and the most important thing is to support LINQ.

I will talk about LINQ later. Now let's talk about transparent activation, the biggest new feature in 7.2 ). For other new features of version 7.0, refer toArticleDb4objects releases db4o 7.0 and supports transparent activation.

To talk about transparent activation, let's take a look at the problems with previous activation. Activation is the process of loading hierarchical objects when objects are loaded from disk files to memory. Because the hierarchical relationships of objects can be infinitely associated, db4o previously used the "depth" concept to clearly specify the layers to be processed when processing objects. However, this method brings a lot of trouble to programming.CodeYou need to always care about how deep objects are loaded. This estimation is sometimes more than used, and sometimes less. More, resulting in a waste of resources, less, and cannot correctly process the objects to be processed.

I will reference the problem below in the db4o document (I will not translate it in English ):

We can reuse most of the code from the deep graphs chapter and get it to work with transparent activation.
As a first step we shoshould fill up our database with car, pilot and sensorreadout objects, so we have some objects to work.

// Storecarandsnapshots
Pilot = new pilot ("Kimi Raikkonen", 110 );
Car car = new car ("Ferrari ");
Car. Pilot = pilot;
For (INT I = 0; I <5; I ++)
{
Car. snapshot ();
}
DB. Store (CAR );

If we now rerun the code to traverse all cars and their sensor readings, we are again confronted with the same problem that we had before, we end up with some leaves of our object graph being null.

// Retrievesnapshotssequentially
Iobjectset result = dB. querybyexample (typeof (CAR ));
Car car = (CAR) result. Next ();
Sensorreadout readout = car. history;
While (readout! = NULL)
{
Console. writeline (readout );
Readout = readout. Next;
}

To solve this problem, db4o put forward the concept of transparent activation in 7.0, that is, db4o transparently helps us solve the problem of object activation. This will provide performance, making programming easier.

Reference the code of db4o again:

Let's configure db4o to run in transparent activation mode and let's try again:

// Configuretransparentactivation
Db4ofactory. Configure (). Add (New transparentactivationsupport ());

// Retrievesnapshotssequentially
Iobjectset result = dB. querybyexample (typeof (CAR ));
Car car = (CAR) result. Next ();
Sensorreadout readout = car. history;
While (readout! = NULL)
{
Console. writeline (readout );
Readout = readout. Next;
}

Wow it worked! Is it really that easy? Principally yes. When db4o is run in transparent activation mode there are no surprises with null members that have not yet been read from the database.

Now let's talk about transparent activation. Now let's take a look at the support of LINQ. Prior to the release of the 7.0 version of LINQ, there was already a LINQ to db4o project on db4o. Now, we only need to merge the LINQ to db4o into the 7.2 release.

LINQ to db4o provides an additionalProgramSet:Db4objects. db4o. LINQ

To use LINQ to db4o, you only need to reference this Assembly in the project. Open a db4o database, and you can use the LINQ syntax to query data:

Let's prepare some objects in our database to query against:

// Storeobjects
DB. Store (new car ("Ferrari", (new pilot ("Michael Schumacher", 100 ))));
DB. Store (new car ("BMW", (new pilot ("Rubens Barrichello", 99 ))));

The simplest LINQ query will look like this:

// Retrievepilot
Ienumerable <pilot> result = from pilot P in dB
Where p. Name. startswith ("Michael ")
Select P;
Listresult (result );

You can see that we are using db4o object container as a datasource, the rest of the syntax is generic to all LINQ queries.
Now let's try a bit more complex selection:

// Retrievepilotbycar
Ienumerable <pilot> result = from car C in dB
Where C. model. startswith ("F ")
& (C. Pilot. Points> 99 & C. Pilot. Points <150)
Select C. Pilot;
Listresult (result );

In addition, there is also an example of LINQ to db4o: LINQ is here!

Querying db4o through LINQ does bring a lot of convenience. However, currently, LINQ to db4o is not very mature and we expect it to be more mature and mature.

If you are interested in db4o 7.2, please download it here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.