Who Are We?

Fluent Consulting is a software development and consulting firm that specializes in enterprise application integration, web applications, and software product development. We are a dedicated team focused on providing the highest level of quality and value for our clients.

Please feel free to visit our corporate site or get in touch!


An Object Relational Mapper for .Net.


Getting Started

The first step in using Inform is to set up the configuration in your application's config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <section name="inform" type="Inform.Common.DataStoreConfiguration, Inform" />
  </configSections>

  <inform>
    <dataStore 
      name="Main" 
      connectionString="server=localhost;database=Example;uid=...;pwd=..." 
      createOnInitialize="True"
      >
        <typeMapping type="Example.Employee,Exampler" />
        <typeMapping type="Example.Task,Example" />
      </dataStore>
  </inform>

To start up Inform use DataStore.Initialize. In an ASP.NET application, you can place the following code in your Global.asax code-behind.

using Inform;
...     
  protected void Application_Start(Object sender, EventArgs e) {
    DataStoreServices.Initialize();
  }

Defining Mappings

Inform supports mapping objects to a data source with attributes or through a configuration file.

Defining a mapping with attributes.

using Inform;
... 
public class Employee {

[MemberMapping(PrimaryKey=true,Identity=True)] public string EmployeeID;
[MemberMapping(length=10, AllowNulls=false)] public string FirstName;
[MemberMapping(length=20, AllowNulls=false)] public string LastName;
[MemberMapping(length=30)] public string Title;

}

Or the alternative method of defining a mapping using a configuration file.

<typeMapping type="Example.Employee,Example">
<memberMapping member="EmployeeID" primaryKey="true" identity="true" />
<memberMapping member="FirstName" length="10" allowNulls="false" />
<memberMapping member="LastName" length="20" allowNulls="false" />
<memberMapping member="Title" length="30" allowNulls="false" />
</typeMapping>

That's it, now you are ready to start using Inform. If you have set 'createOnIntialize' to true, the necessary tables will be created for you when you call Initialize.

Basic Operations

Inserting an object.

Employee e = new Employee();
e.FirstName = "Sam";
e.LastName = "Donaldson";
e.Title = "Manager";
DataStoreServices.Default.Insert(e);

Console.WriteLine("Inserted new employee, EmployeeID={0}", e.EmployeeID)

Updating an object.

e.Title = "Director";
DataStoreServices.Default.Update(e);

Deleting an object.

DataStoreServices.Default.Delete(e);

//Or delete by using primary key only
int employeeID = ...
DataStoreServices.Default.Delete(typeof(Employee), employeeID);

Finding Objects

Finding an object by primary key.

DataStore dataStore = DataStoreServices.Default;
int employeeID = ...
Employee e = (Employee)dataStore.FindByPrimaryKey(typeof(Employee), employeeID);

Finding an object by a filter.

IFindObjectCommand command = dataStore.CreateFindObjectCommand(
                typeof(Employee), "WHERE Title = 'CEO'");
Employee e = (Employee)command.Execute();

Finding a collection of objects.*

IFindCollectionCommand command = dataStore.CreateFindCollectionCommand(
                typeof(Employee), "WHERE Title = @Title");
command.CreateInputParameter("@Title", "Manager");
IList employees = command.Execute();

* Parameterized filters as shown in this example are recommended for both performance and security.

Using Delayed Loading

Using a CachedCollection.

IFindObjectCommand command;
...
Employee e = (Employee)command.Execute();

//The first access of a CachedCollection will load the related tasks.
foreach(Task t in e.Tasks){
    Console.WriteLine("Task: {0}", t.Description);
}

Defining a CachedCollection with attributes.


public class Employee {
    
    [MemberMapping(PrimaryKey=true,Identity=True)] public string EmployeeID;    
    ...

    [RelationshipMapping(Name="Employee_Tasks", ParentMember="EmployeeID", 
        ChildType=typeof(Task), ChildMember="AssignedEmployeeID"]
    private CollectionCache taskCache = new CollectionCache();

    public IList Tasks {
        get { return this.taskCache.CachedCollection; }
    }

}

Defining a CachedCollection in a configuration file.

<typeMapping type="Example.Employee,Example">
    <memberMapping member="EmployeeID" primaryKey="true" identity="true" />
    <memberMapping member="FirstName" length="10" allowNulls="false" />
    <memberMapping member="LastName" length="20" allowNulls="false" />
    <memberMapping member="Title" length="30" allowNulls="false" />
    <relationMapping member="taskCache" name="Employee_Tasks"
        parentMember="EmployeeID" 
        childType="Example.Task,Example"
        childMember="AssignedEmployeeID"
        />
</typeMapping>

Working with Relational Data

TODO

Advanced Configuration

TODO

Creating Storage Run Time

TODO













Copyright © 2002-2003 Fluent Consulting. All rights reserved.