This library is designed for supporting OPEN WEBLIGHTS DBAWARE COMPONENT FOR .NET , to understand it i refer you to my last article about weblights on: http://www.codeproject.com/Articles/189276/MVC-PLUS-for-MVC-NET-3-00
Download the attractive Presentation about this open project on https://sourceforge.net/projects/mvcplus/files/Presentation%20and%20Documents/ or download sample files from https://sourceforge.net/projects/mvcplus/files/
This entity framework is designed and used in very large scale projects such as two ERP systems and support the major RDBMS:
MSSQL SERVER 2005 and higher (2012 extensions ready)
Oracle 10G or higher
MYSQL
POSTEGRESQL
INTERBASE
FIREBIRD
IXML DB
Many of users like to use a
DataAware model in their MVC.NET programs and also, they might have problems
with their current using entity framework, this entity framework is an
open/easy to use with a certain focus on MVC model with implementing an
additions to MVC model such as meta models.
Also I like to have always
sorted/filtered and fast Data Source without using bad and untyped classes such
as DataTable and this is why we created this system, it born some years ago in
idea and finally becomes more and more advanced,
We combined Views and Models as a
3D model which can support recursive data inside even, always sorted, always
filtered.
It have it's own ORM with many
additions such as (mostly built in ):
- 3D models
instead of FLAT Models (completely different concept)
- Built in support
for strategy pattern
- Much faster
batch actions
- Advanced
security Model based on strategy (on metamodel,model,row,column)
- Lock/Unlock and
versioning for concurrency
- Support for many
new fields such as XML Fields in new way of handling,
- ECB
(multi currency which means a user will see the amount of money in his own
culture but storage is different: you entered 100US$ but the European use will
see 80EURO)
- Units
: you entered 2 KG US user will see 4.2 Pounds
Any many more.
In the sample file, we have some
samples of how you can use it? The syntax and a presentation + Complete source
code of the system.
Here we have some sample codes :
Int64 s = Environment.TickCount;
for (var t = 0; t < 500; t++)
{
Test.Person.Insert();
Test.Person.Name = t.ToString() + "th Name";
Test.Person.Post();
}
Test.Person.Flash();
Test.Person.Done();
InsertLabel.Text = "500 Records are inserted in " + (s - Environment.TickCount).ToString() + " Ms";
Test = new MetaModels.Test();
We Insert 500 records in Person
model, this will need 567 Ms in a 2.66 Intel Dual core System.
It is a very Delphi like usage of
syntax, first, you have to do a command, such as Insert, Update or Select and
then post your command, in batch actions you must flash them but when you
select it is not required to flash your request , finally, when your job is
done you must Done all the requests this measn you will clear your request
body.
In this system , we have also XML
fields, but how we can use them? We have a sample of working with XML , this is
different with all other available XML DB implementations, it have a built in
support inside the code :
Using and working with a
WLXMLElement with a Database like pattern:
var xmlelement = new WLXMLElement();
for (var T = 0; T < 200; T++)
{
xmlelement.Insert();
xmlelement["Person/Name"].Value = "RYAN";
xmlelement["Person/FamilyName"].Value = "SAMIEE";
xmlelement["Person/Age"].Value = "32";
xmlelement["Person/Age/Description"].Value = "He is yoo young";
}
The Code inside show how is easy
to insert XML elements inside, just use XML Path for example:
Person/Name/X/Y
It will create the nodes, will
insert the value where you need it, then you can save it to disk simply with
SaveAsFile command or in ORM it will be a field and system will store it as a
field, in addition you can sort in application server base on XML data,
Grant Policies:
You can to have a security model
as below:
Both are supported by hardcode
and XML mapping for XML and Models:
[ReadOnly(Where="owner!=me and owner!=admin",WhichFields("Name")]
[WriteOnly(Where=" owner!=admin",WhichFields("Password")]
[CanWrite(Where="owner!=me and owner!=admin",WhichFields("Name")]
[CanRead(Where="owner!=me and owner!=admin",WhichFields("Name")]
You can made them
readonly/writeonly or readable or writable when ever you wish to simply with
that simple syntax.
Test.Person.Update(new { name = "@EXP name+' test'" }, "");
Test.Person.Flash();
Test.Person.Done();
Comparation of Speed
With the samples, we compared
speed of this system against regular batch actions ,as it is using an optimized
way to handle batch actions it is 4 to 10 times faster than regular codes
below.
Also you can see how expression
system handles the things, a sample of it's usage + Expression tree it creates.
Please note that:
Sample code is in attachment of
this article + FULL SOURCE CODE of OPEN MVC PLUS.
Batch actions, it is several
times faster than it's competitors.
Test For Expressions
Expression : (Name+' '+Familyname)+Replace('Ryan','R','r')
Result: Ryan Samiee ryan
Also you can see expression tree
Expression Library is Based on Ryan Samiee Expression
Library originally written in C in 2002(Closed Source) re written In C# and
Java.
Note: to run the sample , please do the following
actions:
After unzip please modify the file in Project
TestApplication\DAL\BaseModel:
[WLMOAdapter(WLAdapterType.MSSQL, ConnectionString: "Data
Source=.\\SQLEXPRESS;AttachDbFilename=O:\\WindowsFormsApplication9\\Backup4\\WindowsForms
Application9\\MVCPLUSTEST.mdf;IntegratedSecurity=True;User Instance=True")]
Change the bold path (attachdbfilename to exact path of
MVCPLUSTEST.MDF file and note that you need to run this sample on latest SQL
Express and Visual Studio 2010.
More :
In the text below you can see a brief information on this
system.
Also please download the attachment or join MVC PLUS at http://sourceforge.net/projects/mvcplus/
Note that: you can use Expression or XML library in your own
way and they are separated from the core of MVC PLUS Entity Framework.
MVC PLUS Is an open source entity
framework designed to support OPEN WEBLIGHTS and generally for MVC and
enterprise applications such as ERP (some ERP products are using It's dynamic
specifications heavily), it have it's own developed ORM system with new
specifications such as :
- Built
in support for ECB
- Fast
and reliable expression Library
- Built
in support for XML Fields (with a XML DB kind)
- Fast
and transparent ORM.
- Great
and fast DB actions for example you can insert 1000 records in one seconds
which 10 times faster than normal db actions.
- This
is a similar to old VCL with a new engineering for fastest possible actions.
- Models
are always in actual state: SORTED and FILTERED.
- Python
application server triggers
- Ideal
for MVC Projects
Also you can do rest of your jobs
with no code, just set behavior of each business entity and they will do the
rest of job, in other hand, system have a transparent ORM which will let your
job immediately synchronized with RDBMS and even, in client side validation
and types will change depends on your RDBMS.
Please download the attachment
file to get an update and also you can attend to MVC Plus project at source
forge with the following address: http://sourceforge.net/projects/mvcplus/
It have a lot of advantage over
other available ORM's such as Entity framework and NHibernate, it can be used
in all other projects but you can get advantage of this tested and stable
system in most cases.
-
Built in support for Dynamic Strategy pattern
-
Using a behavioral architecture instead of creational ones
Similar design to VCL Data
components
Support for stateless and state
full operations
Models: (other entity
frameworks are mostly using a flat model)
-
Multi Level Models
- 2D model (Rows)
- 3D (Recursive and Rows)
- Multi Level Models
-
Combined class and view
Expressions: (sample)
-
(BirthDate>'27/1/2011 and BirthDate<'27/2/2011) or
BirthPlace=='TEHRAN'
@EXPR Replace(Address,'Tehran','Greate Tehran') where BirthPlace=='TEHRAN
Expressions are used in:
-
Filters
-
Policies and Strategies
-
Formula fields
-
All possible Commands
Expression Commands
Group | Canonical
functions[21]
|
Aggregate functions | Avg, BigCount, Count, Max, Min, StDev,
StDevP, Sum, Var, VarP |
Math functions | Abs, Ceiling, Floor, Power, Round, Truncate |
String functions | Concat, Contains, EndsWith, IndexOf, Left,
Length, LTrim, Replace, Reverse, Right, RTrim, Substring, StartsWith,
ToLower, ToUpper, Trim |
Date and Time functions | AddMicroseconds, AddMilliseconds, AddSeconds,
AddMinutes, AddHours, AddNanoseconds, AddDays, AddYears, CreateDateTime,
AddMonths, CreateDateTimeOffset, CreateTime, CurrentDateTime,
CurrentDateTimeOffset, CurrentUtcDateTime, Day, DayOfYear, DiffNanoseconds,
DiffMilliseconds, DiffMicroseconds, DiffSeconds, DiffMinutes, DiffHours,
DiffDays, DiffMonths, DiffYears, GetTotalOffsetMinutes, Hour, Millisecond,
Minute, Month, Second, Truncate, Year |
Bitwise functions | BitWiseAnd, BitWiseNot, BitWiseOr, BitWiseXor |
Other functions | NewGuid |
Sample usage : (C# code below)
-
Profiles.Person.Update(new { name = "@EXP name+' test'"
}, "BirthPlace=='Tehran' and Age>45");
-
[FormulaField("DifferenceYears(Now,BirthDate)"]
-
public int Age{get;set;}
-
[ReadOnly("@WHERE owner!=CurrentUser"]
- public bool Interested{get;set;}
- Profiles.Person.Filter="Editor==ME and ";
Controls and Security
-
MetaModels (equative to views)
-
Models
-
Rows
-
Columns
Support for Policies
FullAccess,Readonly,WriteOnly,Delete
Compatible With
-
LINQ
-
Expression Query Requests
And integrated with WEBLIGHTS as
default supported DAL.
-
Cursor (Multi Level Cursor Supported)
-
Lazy Load Search
-
Sort
-
Filter (Complex Expression supported)
-
Group By
EXTENSIBLE EXPRESSION SUPPORT for
rest of commands.
Optimized for batch operations
Always Sorted and filtered
Available DB Scenarios
-
MultiMaster/MultiDetail
-
One to One
-
One to Many
-
Recursive
-
Self recursive
- Many to many
-
Many to many
MultiMaster/MultiDetail
Supported Types
-
String
-
Cardinals
-
Floatings
-
Currency (ECB Support)
-
Units (Exchangeable Units)
-
GUID
-
DateTime and Time
-
Binary
-
Streams (Application Server and RDBMS)
-
Images
-
XML
-
Custom (formula fields)
Available Validators
-
Type
-
Max and Min
-
Range
-
Scale
-
Format
-
Requirement
-
Row
-
Custom
Some Other Commands
-
Cursor (Multi Level Cursor Supported)
-
Lazy Load Search
-
Sort
-
Filter (Complex Expression supported)
-
Group By
Sample code for Insert of 5000
record (will need around 3 to 4 seconds to complete in a normal dual core 2.66
Intel machine )
Try{
for (var t = 0; t < 5000; t++)
{
try{
p.Person.Insert();
p.Person.Assign(new { aname = "Ryan", aFamilyName = "Ali" }, "name=aname;
familyname=afamilyname");
p.Person.Name = t.ToString() + " test ";
p.Person.FamilyName = t.ToString() + " test ";
finally{
.Person.Post();
}
}
p.Person.Flash();
}catch{
p.Person.Cancel();
}
TRY
Insert or Update Or Delete
Set Values ‘p.person.Name=“ALI”;
FINALLY
Post
Flash
CATCH
Cancel
XML Support
Additional to XDOM , Support for
XML DB :
In Models:
Person["Name/MiddleName"];
XPATH and XQUERY Extensible Support
Device ["features/Supports"].Insert();
Device ["features/Supports/DeviceName"].Value="Data";
Device.Post();
Filter/Policies and expressions are supported in rest of XML Support.
Mapping
Physical XML Mapping
-
Table specification
-
Triggers : Sequence
-
Stored Procedures : Sequence
-
Keys : Sequence
-
Relations: Sequence
-
Fields : Sequence
Support for deployment (Installation)
Logical XML Model Mapping
-
[Connection]
-
Tables specification (Sequence)
-
Python Triggers (Sequence)
-
Python Stored Procedures (Sequence)
-
Keys (Sequence)
-
Relations (Sequence)
-
Fields (Sequence)
Meta Model XML Mapping
-
Model Relations
-
Profiles and policies
-
Behaviors
-
Components Behaviors
Model Hard Code Mapping (Model Hard Code Mapping)
Sample MetaModel
WLMOAdapter(WLAdapterType.MSSQL, ConnectionString: “@INDB”)]
[WLMOTableInfo("address;person;addresstype")]
[WLMOCommandInfo("select","", WLCommandType.ORM, WLIOMode.Read)]
[WLMOCommandInfo("update", "", WLCommandType.ORM, WLIOMode.Write)]
[WLMOCommandInfo("delete", "", WLCommandType.ORM, WLIOMode.Write)]
[WLMOCommandInfo("insert", "", WLCommandType.ORM, WLIOMode.Write)]
public class Address : WLModel<APerson>
{
[WLFField(dbFieldName: "Address.Address")]
[WLFDisplayName("ryan", Language: WLLanguages.Default)]
public string FullAddress
{
get { return (string)this["FullAddress"]; }
set { this["FullAddress"] = value; }
}
[WLFField(dbFieldName:"PersonID")]
[WLFForeignKey("Person", "PersonID")]
...
Sample HARD CODE MetaModel:
(C# code below)
[WLMMDefaultProfile("Admin;@EXPR UserType=44")]
public class metamodel : WLBaseMetaModel
{
[WLMODisplay("@ADDRESS")]
[WLMOAutoCreate]
[WLMOConnectTo("Person”)]
public Address Address { get; set; }
[WLMODisplay("@PERSON")]
[WLMOAutoCreate]
public APerson Person { get; set; }
}
WEB FARMS Scenario
-
All requests should go for the same machine
MORE
-
Each user will need approximately 20 to 30MBytes
-
Possibility to implement ISO/IEC 27001