Create Entity
To persist an Entity using the EntityManager, you will have to do the following: Note* this is an example.
using ( EntityManager manager = new EntityManager() )

    Employee employee = new Employee( );
    employee.Empid = "L-M31947F";
    employee.Fname = "Mr Ahmed";
    employee.Hiredate = DateTime.Now;
    employee.Job = manager.Limit<Job>( 0 , 1 ).First( );

    employee.Joblvl = 10;
    employee.Lname = "Salako";
    employee.Minit = "M";
    employee.Publisher = manager.Limit<Publisher>( 0 , 1 ).First( );
    //Here is the actual creation.
    manager.CreateNewEntity<Employee>( ref employee );

The above code creates a new instance of an Employee with an existing Job and Publisher. There is a Cascade operation on child entities, in this situation, if you set the relationship of Employee and Job to Cascade upon creation, changes made to Job will be updated too.

Update Entity
Updating Rapid Entities automatically triggers Change Tracking via the RRE (Rapid Runtime Engine). Changes are stored in a transactional cache, which is linited to the scope of the current EntityManager .

employee.Fname = "Ahmed";
manager.SaveEntity( employee );

The above example changes the name from "Mr Ahmed" , to "Ahmed" . If at the point of this changes (Before Committing), another thread is reading this entity, the thread will read "Mr Ahmed" because the changes are stored in a transactional cache which is known to the instance of that EntityManager.

Delete Entity
Delete removes the object from the underlying datastore upon commit, and the object is evicted from the Shared cache. The following is a simple way of deleting objects.
manager.RemoveEntity( employee );

Note* complex objects with cascade defined on them will remove related entities too.

Last edited Feb 4, 2010 at 6:21 PM by ahmedsalako, version 5


No comments yet.