Easy Data Object Relational Mapping Tool
-
Upload
hasitha-guruge -
Category
Documents
-
view
644 -
download
0
description
Transcript of Easy Data Object Relational Mapping Tool
Developer Friendly Object-Relational Mapping Tool for Microsoft .NET
EasyData
Hasitha Guruge2008/MCS/021
Your Logo
• “EasyData” is an open source, developer friendly Object-relational mapping tool for Microsoft .NET which has been developed based on C#.NET language. It enables developers to use it with databases such as MS SQL, MySQL and Oracle.
IntroductionWhat is “EasyData”?
Primary Objectives
Objectives
Your Logo
Develop an object-relational mapping tool with basic functionalities
Ability to use inheritance and polymorphism and create hierarchies between entities
Support for transaction based data operations
Support for Microsoft .NET Web/Windows Applications
Handle relationships such as 1-1, 1-n, n-1 and n-n
Support for Aggregations and SQL Grouping6
5
4
3
2
1
Easy configuration and relatively low learning curve
Has its own Query Language (OQL)
Support for multiple Databases (MS SQL, MySQL, Oracle)
Support for Data Binding of components in .NET
4
3
2
1
Secondary Objectives
✓
✓
✓
✓
✓
✓
✓
✓
• In Applications Data Access Layer is the layer which deals with data.
• Object-Relational Mapping is one way to automate this DAL by reducing redundant work and higher risk of errors.
• ORM Tools create a bidirectional link between relational database and objects in an application.
DAL & ORMCore concepts behind the project
Your Logo
- Open Source- Complex Configuration- Huge Learning Curve- Mapped via XMLs- Multiple Database Support
- Open Source- Extension to NHibernate- Mapped without XMLs / Separate Mapping Layer- Complex Configuration- Huge Learning Curve
- Open Source- Use Active Record Design Pattern- Based on NHibernate- Mapped without XMLs via same Entity Object- Since it is based on NHibernate, same disadvantages exist here as well
Related Projects
NHibernate
Castle Project
ActiveRecord
Fluent NHibernate
Major tools based for the project
Your Logo
Microsoft or Private ProjectsRelated Projects
Only with .NET Framework 3.5 or higher. DBML file provides the mapping functionality.
LINQ to SQL
LINQ to SQL and ADO.NET Entity Framework have their own limitations such as lack of support for MySQL and no support for the lower versions such as Framework 1.1, 2.0 likewise.
nHydrate was a private project till Sep, 2009 and built on .NET Framework 3.5 to work exclusively with MS SQL Server.
Studied related work and extracted the important features to incorporate with EasyData.
1
Only with .NET Framework 3.5 or higher. Uses Active Record pattern.
ADO.NET Entity Framework
2
Uses Active Record Pattern in core of DAL. Since it was a private project it is not so popular.
nHydrate
3
ER
Dia
gra
m to
pe
rfo
rm te
stin
g
EasyData DesignComponent Diagram – with extended features
ImplementationImplementation Process
Your Logo
With Basic Features
R & D Existing Tools
With Extended Features
Your Logo
Sample Insert Method with TestingHow It Looks Like
This is a sample code to tests the Save() functionality. The “ProductCategory” is a sample table that has many Sub Categories under that. The “easySession” responsible for the database connection and the transaction of the record insert. All executions within one session is handled under the same transaction. Simply create an instance of the object and assign values to the instance and simply call Save() function.
[Test] public void SimpleCreateTest() { using (EasySession easySession = new EasySession()) { ///[Test Create] - without relationship ProductCategory productCategory = new ProductCategory(); int resultCount = productCategory.Count(easySession); Assert.AreEqual(4, resultCount);
productCategory.Name = "Test Category"; productCategory.Rowguid = Guid.NewGuid(); productCategory.ModifiedDate = DateTime.Now; productCategory.Save(easySession);
resultCount = productCategory.Count(easySession); Assert.AreEqual(5, resultCount); } }
EasyData HierarchyHow the components interact with each other?
public abstract class EasyDataBase<T> {………….…………….}
public class EasySave<T> {………….…………….}
public class EasyUpdate<T> {………….…………….}
public class EasyDelete<T> {………….…………….}
public class EasySelect<T> {………….…………….}
Custom Attributes
DB Specific Library- MS SQL
- MySQL- Oracle
public class EasySession : IDisposable {………….…………….}
Database
public class ProductCategory{}
public class ProductCategory{}
public class ProductCategory{}
Configuration File
Obj
ect Q
uery
Cla
sses
Code Behind Files(aspx.cs or aspx.vb)Code Behind Files
(aspx.cs or aspx.vb)Code Behind Files(aspx.cs or aspx.vb)
Conduct a literature survey on existing and popular ORM tools which are used in .NET Framework and understand their architectures , basic operations and features
Enhance the tool with new effective and flexible features as a separate R & D task
Release the functional tool as a beta version to use with the developments of target users’
Implement a mapping tool with basic features such as CRUD operations with the support of relationships among tables/entity objects
Test the tool using a sample common database or generated data from another mapping tool
Conduct a survey to collect and identify developer needs and feedbacks
Your Logo
Initial ScopeScope of the Project
1
2
3
4
5
6
Unable to go through the all features and functionalities of all popular tools due to their complexity and time constraints
R & D Phase was dragged more than expected, due to the complexity and huge learning curves of existing tools
The final survey is not conducted, since the developments were delayed and release of the beta version without enough time to perform the testing by target users
Unable to build in-built functionalities to support all aggregation and grouping functions due to the time constraints
Unable to deliver the beta version on time and let it be tested by the target users, currently it is available for the target users for testing
Unable to complete the OQL (Object Query Language) and its functionalities and is currently available as a basic version towards that
Your Logo
Deviations from the InitialScope of the Project
1
2
3
4
5
6
ConclusionThe final result
Your Logo
The beta version of the implemented tool is available on http://www.future-needs.net/easydata
Since it is an open source tool the windows binaries as well as the source is available online.
A survey to collect developers’ expectations and experience with another popular tools is provided before download of the tool.
Implement object query language (OQL) as it is in an integrated query language (LINQ)
Build a standalone tool or integrated tools to generate entity class files with mapping related details by reading the database tables and relationships
Implement a parameterized way to call functions which contains strongly typed variables for the different database types instead of implementing the same method repetitively by checking the database type
Implement more in-built functionalities to provide more flexibility in data selection
Optimize the auto generated queries and the process of building queries to improve the performance of the tools
Implement a good library for different query languages which contains keywords, reserved words and special scenarios for those languages to handle scenarios such as following SELECT TOP example.
Your Logo
Steps towards a stable & rich toolFuture Enhancements
1
2
3
4
5
6
SELECT * FROM parts WHERE name = 'gearbox' LIMIT 1; -- MySQL or PostgreSQL SELECT * FROM parts WHERE name = 'gearbox' AND rownum < 2; -- Oracle SELECT TOP 1 * FROM parts WHERE name = 'gearbox'; -- Microsoft SQL Server
THANK YOU!
Your Logo