Project Description
DBFramework is an object/relational mapping tool for .NET environments. The term object/relational mapping (ORM) refers to the technique of mapping a data representation from an object model to a relational data model with a SQL-based schema.
DBFramework can not only map from .NET classes, which are marked with attributes, to database tables, but also can map from database tables to .NET classes , and provides data query . Then it can significantly save your time on handling with SQL and ADO.NET manually.

Sample project: http://tradetracking.codeplex.com/

Example:

Serializable()
Table(TableName "Role")
public class Role :TableGateway<Role>
{
public Role()
{

}

#region Member Variables

private int _roleId;
private string _roleName;
private string _description;

#endregion //Member Variables

#region Properties

Column(ColumnName "RoleId",IsIdentity true)
public int RoleId
{
get
{
return _roleId;
}
set
{
_roleId=value;
base.OnPropertyChanged(MethodInfo.GetCurrentMethod());
}
}

Column(ColumnName "RoleName",IsPrimaryKey true)
public string RoleName
{
get
{
return _roleName;
}
set
{
_roleName=value;
base.OnPropertyChanged(MethodInfo.GetCurrentMethod());
}
}

Column(ColumnName "Description")
public string Description
{
get
{
return _description;
}
set
{
_description = value;
base.OnPropertyChanged(MethodInfo.GetCurrentMethod());
}
}


#endregion //Properties

public static bool ExistsRole(string roleName)
{
Expression exp = Expression.Equal("RoleName", roleName);
return Role.Exists(exp);
}

public static DataTable ListAll()
{
return Role.QueryAll(Order.Ascend("RoleName"));
}

}



1 Getting all rows .
private void BindData()
{
Role role = new Role ();
gridView.DataSource = role.QueryAll();
gridView.DataBind();
}
2 Retrieving an object .
private Role Retrieve(int roleId)
{
Role role = new Role ();
role.RoleId = roleId;
role.RetrieveById();
return role;
}
3 Adding a new object .
private bool AddNewRole()
{
Role role = new Role ();
role. RoleName = "Administrator";
return role.AddNew()>0?true:false;
}
4 Updating an object .
private bool UpdateRole(int roleId)
{
Role role = new Role ();
role. RoleId = roleId;
role. RoleName = "Admin";
return role.UpdateById() > 0 ? true : false;
}
5 Deleting an object .
private bool DeleteRole(int roleId)
{
Role role = new Role ();
role. RoleId = roleId;
return role.DeleteById() > 0 ? true : false;
}
Additional information on starting a new project is available here: Project Startup Guide.

Last edited Jun 12, 2010 at 1:44 AM by Kenly, version 11