This project has moved and is read-only. For the latest updates, please go here.

Once the structure of the database is defined, it is really easy to work with the data entities. Create an instance of the database and use the interface of the table endpoints.

Use the Insert method to add entities to the tables.

MyDatabase db = new MyDatabase();

db.Groups.Insert(new Group { 
    Id = 1, 
    Name = "Alpha Group" });

db.Groups.Insert(new Group { 
    Id = 2, 
    Name = "Beta Group" });

db.People.Insert(new Person { 
    Id = 1, 
    Name = "John Doe", 
    GroupId = 1, 
    BirthDay = new DateTime(1966, 4, 12) });

Query existing entities with the Linq interface. All the Linq features are enabled.

Group group = db.Groups.Single(g => g.Id == 2);

var query =
    from p in db.People
    join g in db.Groups on p.GroupId equals g.Id
    select new { Name = p.Name, Group = g.Name };

Use the Update method to make changes available in the database. The entity is identified by its primary key, so that has to be unchanged.

group.Name = "Gamma Group";

db.Groups.Update(group);

Use the Delete method to remove entities from the database. The entity is identified by its primary key, so that has to be unchanged.

db.Groups.Delete(group);

 

Last edited Nov 10 at 6:25 AM by zzzprojects, version 4

Comments

No comments yet.