AgileFx

AgileFx ORM
Developer(s) AgileHead
Operating system .NET Framework / Microsoft Windows
Type Software framework
Website http://www.agilefx.org

AgileFx is an Open Source ORM for the .NET Framework, with features comparable to ADO.NET Entity Framework. It uses LINQ to SQL underneath, and extends LINQ to SQL to match the more advanced features found in Microsoft Entity Framework; while retaining its performance benefits.

In a nutshell, AgileFx works by translating (at runtime) LINQ queries on Domain Models involving Inheritance and Many-to-Many relationships into simpler queries involving plain database tables, which can be processed by LINQ to SQL or a similar ORM. Hence architecturally, AgileFx is not tied to LINQ to SQL; any LINQ provider which supports queries on table entities (such as IQToolkit) can be used instead.

AgileFx 1.0 beta was released in March 2010, with the final version expected in August 2010.

Contents

Features

AgileFx 1.0 supports the following features:

The primary goal of version 1 was to achieve feature parity with ADO.NET Entity Framework.

Using the framework

AgileFx supports all standard LINQ queries, and the queries are deliberately similar to Entity Framework.

    Entities entities = new Entities();
    var users = from user in entities.User
                where user.Firstname == "Mark" 
                  && user.Designation == "IT Manager"
                select user;
 
    foreach(var user in users)
    {
        Console.WriteLine("Firstname {0}, Lastname {1}", user.Firstname, user.Lastname);
    }

The following is an example of Eager loading. Note that the loaded path (u.Account) is specified as an expression instead of a string for better type safety.

    Entities entities = new Entities();
    var users = entities.CreateQuery<user>().LoadRelated(u => u.Account)
        .Where(user => user.Firstname == "Mark" 
            && user.Designation == "IT Manager");
    foreach( var user in users)
    {
        Console.WriteLine("User lastname {0}, Account Status {1}", 
            user.Firstname, user.Account.Status);
    }

The following is an example of caching. When this method is called for a second time, the objects are returned from the in-memory cache instead of the database.

    public List<User> GetUsers(EntityContext entityContext, long tenantId)
    {
        var cacheParams = new CacheParams 
        {
            ItemKey = "users_" + tenantId,
            Timeout = new TimeSpan(0, 2, 0) 
        };
        var users = entityContext.Cache().Invoke(
            (tId, _context) =>  _context.CreateQuery<User>().Where(u => u.Id == tId).ToList(), 
            this, tenantId, cacheParams);
        return users;
    }

Modeling tools

AgileFx includes designer support for Visual Studio 2008 and 2010, which lets the developer create Domain Models. The designer supports importing the models from an existing database, or a Model-First approach which allows the developer to design the entities first and export them later to a database.

External Links