Friday, July 12, 2013

Introducing PetaPoco for Informix

I've created a fork of PetaPoco, with support for Informix and named parameters. I've also added multiple key support.

The code is available on GitHub.

An example:
[TableName("ship")]
public class Ship
{
    [PrimaryKey]
    [Column("shipid")]
    public int Id { get; set; }

    [Column("name")]
    public string Name { get; set; }
}

[TableName("positionlog")]
public class PositionLog
{
    [PrimaryKey]
    [Column("shipid")]
    public int ShipId { get; set; }

    [PrimaryKey]
    [Column("epochdate")]
    public int EpochDate { get; set; }

    [Column("lat")]
    public int Latitude {get;set;}

    [Column("lon")]
    public int Longitude {get;set;}
}

var db = new Database(new IfxConnection("<ConnectionString>");
int shipId = 1234;
var ship = db.Query<Ship>("select first 1 * from ship where shipid = @id", new { id = shipId }).FirstOrDefault();

ship.Name = "Submarine";

db.Update(ship);

The code will be updated with support of more features as we move along with our project (which uses Informix).

Cheers,
Luuk

No comments:

Post a Comment