MySoft ORM Component
New Version components are not compatible with previous versions, and entities need to be regenerated
In view of the expansion of functions, some classes have been restructured and methods have also changed. The usage methods are basically consistent with those before.
The generation tool can directly generate the corresponding entity class, instead of creating a project.
The original method is retained. To facilitate the design of custom interfaces
Version: 1.6.0
1. MySoft. Data batch processing and transaction processing.
2. Rename Trans to DbTrans, change the BeginTran method to BeginTrans, and add the DbBatch class.
Public void AddMessages (Message [] msgs)
{
// Use Batch Processing
DbBatch batch = DbSession. Default. BeginBatch ();
For (int index = 0; index <msgs. Length; index ++)
{
Batch. Save (msgs [index]);
}
Batch. Process ();
// Use batch processing with transactions
DbTrans tran = DbSession. Default. BeginTrans ();
DbBatch batch = tran. BeginBatch ();
For (int index = 0; index <msgs. Length; index ++)
{
Batch1.Save (msgs [index]);
}
Batch1.Process ();
Tran. Commit ();
// Use a single record for processing
For (int index = 0; index <msgs. Length; index ++)
{
DbSession. Default. Save (msgs [index]);
}
// Use a single transaction
DbTrans tran1 = DbSession. Default. BeginTrans ();
For (int index = 0; index <msgs. Length; index ++)
{
Tran1.Save (msgs [index]);
}
Tran1.Commit ();
}
Version: 1.7.6
Added the IDataPage class to support HtmlPager operations.
Use:
IDataPage <Message []> msgInfo = new DataPage <Message []> (5 );
MsgInfo. RowCount = 15;
MsgInfo. DataSource = null;
String linkFormat = "javascript: gotoPage ($ PageIndex );";
HtmlPager pager = new HtmlPager (msgInfo, linkFormat, 5 );
Pager. NextPageTitle = "Next Page ";
Pager. PrevPageTitle = "Prev Page ";
PageHtml = pager. ToString ();
Version: 1.7.8
1. MySoft. Data corrected the serialization problem of Entity in Remoting.
2. corrected the incorrect SQL statement generated by OrderByClip and WhereClip in Remoting.
Version: 1.8.0.0
Corrected the 'symbol generation error in the condition query value!
Version: 2.0
1. SubQuery operation is added to MySoft. Data.
DbSession. default. from <Message> (). subQuery (). select (Message. _. ID, Message. _. postTime. max ()). groupBy (Message. _. ID. groupBy ). toArray ();
The generated SQL statement is as follows:
Select Message. id, max (Message. posttime) as posttime from (select * from Message) as Message
DbSession. default. from <Message> (). subQuery ("c "). select (Message. _. ID. at ("c"), Message. _. postTime. at ("c "). max ()). groupBy (Message. _. ID. at ("c "). groupBy ). toArray ();
The generated SQL statement is as follows:
Select c. id, max (c. posttime) as posttime from (select * from Message) as c
Group by c. id
2. MySoft. Data corrected the conversion problem of enumeration types after reading from the database.
Version: 2.1.0
Memory query function added by ORM
MemoryFrom <Message> query = DbSession. Default. From <Message> (). ToMemory (); // obtain the Message with the primary key 1
Message msg = query. Get (1); // obtain the array with ID 1, 2, and 3
Message [] msgs1 = query. Where (Message. _. ID. In (1, 2, 3). ToArray ();
// Obtain the page by page. Message. _. ID is required and can be specified as any column.
Message [] msgs2 = query. GetPage (Message. _. ID, 10). ToArray (3 );
Bool exist = query. Exists (Message. _. ID = 1 );
Object obj = query. Where (Message. _. ID = 1). Sum (Message. _. ID );
Version: 2.1.5
1. The Union operation and paging processing are added. The Union operation entity can also perform paging operations.
2. Fixed the bug of correlated entities for multi-Association errors in Access.
3. Fixed the paging query bug in Access.
4. Fixed the bug where the table name is incorrect if the alias is used in the Join operation and the field is not selected.
5. Modify the field name and attribute name in the correlated object in EntityDisign.
If the field name is {ID} but the attribute name or ID cannot be found and is not included in {}, an error is returned.
6. Fixed the bug where Oracle, MySql, SQLite, and FireBird obtained the inserted data and obtained the current record number incorrectly.
Version: 2.2.5
1. Fixed some bugs that do not often occur during project development.
2. Add the returned error list to the batch processing.
3. added the processing of custom table names. In many cases, table sharding is required. In the past, single table names were defined.
Therefore, you must input a table name to operate a specific table.
The following function saves the user entity to the table UserTest
DbSession. Default. Save <User> (new Table ("UserTest"), user );
Excessive intermediate version 2.4.0. the following updates will be incompatible with previous versions
......
Version: 2.5.0
1. added the add, delete, modify, and query creators.
QueryCreater
InsertCreator
UpdateCreator
DeleteCreator
2. Supports database queries without generics.
QueryCreator q = QueryCreator. NewCreator ()
. From ("user ")
. AddField ("userid ")
. AddField ("username ")
. AddWhere ("groupid", 1 );
DbSession. Default. From (q). ToTable ();
DbSession. Default. From (q). ToList <T> ();
DbSession. Default. From (q). ToListPage <T> ();
3. Perfect support for Oracle, FireBird, and SQLite
4. You can generate a method without modifying attributes. You need to set EntityDesignConfig. xml
If EnabledPropertyValueChange is true, it is generated. Otherwise, it is not generated.
For multi-threaded operations, you can choose not to generate the OnPropertyValueChange method to improve performance
Version: 2.5.6
1. Fixed the bug where the Get (params object [] pkValues) error occurs when multiple primary keys are used;
2. Fixed the Data Query error bug when the Oracle driver time format is not yyyy-MM-dd HH: mm: ss;
3. added a new distribution class to obtain data, such:
The system already has a User entity.
Public partial class User {
Public int UserID {get; set ;}
Public string UserName {get; set ;}
}
Extend an attribute for the User
Public partial class User {
Public string GroupName {get; private set;} // read-only
Protected override void SetExtValues (ISourceReader reader)
{
If (false = reader. IsDBNull ("GroupName "))
{
This. GroupName = reader. GetString ("GroupName ");
}
}
}
DbSession. Default. From <User> (). LeftJoin <Group> (User. _. GroupID = Group. _. GroupID)
. Select (User. _. All, Group. _. GroupName). ToList ();
In this way, the User has the GroupName attribute and does not need to re-design an object.
In addition, the addition and modification operations are not affected by the extra attributes.
Version: 2.5.8
1. added the ISourceList class to implement data grouping.
ISourceList source = new SourceList (IList <User> list );
Source. ToDictionary <int> (User. _. GroupID );
Or
Source. ToDictionary <int> ("GroupID ");
The IArrayList interface also has several other methods.
2. Enhanced memory Query
ISourceList source = new SourceList (IList <User> list );
MemoryFrom <User> mf = source. ToMemory ();
Or
MemoryFrom <User> mf = DbSession. Default. From <User> (). ToMemory ();
Mf. Where (User. _. UserID = 1). ToSingle ();
Mf. Where (User. _. GroupID = 1). OrderBy (User. _. AddTime. Desc). ToList ();
// Get 2nd pages, 2 entries per page
Mf. Where (User. _. GroupID = 1). GetPage (2). ToList (2 );
3. Change DataPage to avoid conflict with System. Data. DataPage.
Change ToDataView () to ToListPage ()
Version: 2.6.0
1. parameterization of WhereClip generation to completely solve the problem of SQL Injection
2. The QueryCreator function is enhanced.
QueryCreator q = QueryCreator. NewCreator ()
. From <User> ()
. Join <Group> (User. _. GroupID = Group. _. GroupID)
. AddField (User. _. All)
. AddField (Group. _. GroupName );
Or
QueryCreator q = QueryCreator. NewCreator ()
. From ("user ")
. Join ("group", "user. groupid = group. groupid ")
. AddField ("user ","*")
. AddField ("group", "groupname ");
DbSession. Default. From (q). ToList <User> ();
DbSession. Default. From (q). ToTable ();
3. supports post-configuration of table prefixes
Add an EntityConfig. xml method to the web Project. The configuration is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<ArrayOfPrefixSetting xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema">
<PrefixSetting Name = "Default" Value = "tb _"/>
<PrefixSetting Name = "EntityNamespace" Value = "tb _"/>
</ArrayOfPrefixSetting>
Default: If EntityNamespace is not set, this prefix is used by Default.
EntityNamespace: Entity Assembly namespace, such as Simple. Entity
EntityNamespace can be multiple, so that different command spaces can use different prefixes
This facilitates the use of the same data by multiple applications.
Version: 2.6.5
1. Fixed the bug that occurs when parameters are used for complex conditions, such as subqueries In (Query) and Union queries.
2. added the MySql driver. MySql. Data. dll needs to be loaded.
3. added the data types IArrayList <T> ISourceList <T> ISourceTable and ISourceReader.
Using the above types can greatly enhance the operability of returned data
The ISourceReader interface allows you to obtain data by fieldName and Field.
IArrayList implements the ToArray Method
ISourceList implements the data conversion convertor method, ToGroup method, and ToMemory method.
ISourceTable implements the ToList <T> method and ToMemory method.
The Get <T> () method is changed to the Single <T> () method, and a Single object is returned.
Change ToFirst () method to ToSingle () method
The ToList method remains unchanged, but the returned type is ISourceList.
The ToDataTable method is changed to ToTable, And the return type is ISourceTable.
The ToDataReader method is changed to ToReader, And the return type is ISourceReader.
4. added an Interface Programming Method to decouple the application, using the following:
Public interface IUser {
UserID {get; set ;}
UserName {get; set ;}
}
Public class User: IUser {
Public int UserID {get; set ;}
Public string UserName {get; set ;}
}
The following ToList () returns the ISourceList type <T>. You can use the convertor <T> method to convert the data.
IList <IUser> list = DbSession. Default. From <User> (). ToList (). convertize <IUser> ();
DbSession. Default. Save (IUser as User );
5. added the DataUtils. ConvertType <T, TOutput> method to support conversion of string data types.
Public class User1 {
Public string UserID {get; set ;}
Public string UserName {get; set ;}
Public string BornDate {get; set ;}
}
Public class User2 {
Public int UserID {get; set ;}
Public string UserName {get; set ;}
Public DateTime BornDate {get; set ;}
}
User1 user1 = new User1 () {UserID = "1", UserName = "test", BornDate = "2009-09-10 "};
User2 user2 = DataUtils. ConvertType <User1, User2> (user1 );
Version: 2.6.6
1. Optimized Oracle paging data query performance
Version: 2.6.8
1. Fixed the bug where the returned results were incorrect when obtaining the first N records.
All data is returned before. GetTop (5). ToList ().
Restructured the Top structure and added the Top query In the In syntax.
2. Fixed the parameter processing error bug in Access-driven paging query.
3. Important reconstruction of the Insert, Delete, and Update operations Kernel
4. Added support for postgreSQL databases.
Version: 2.7.0
1. added the method for outputting data from ISourceReader to List.
2. added custom Oracle series names
Public class UserGroupInfo
{
Public int UserID {get; private set ;}
Public string UserName {get; private set ;}
Public string GroupName {get; private set ;}
}
// First return ISourceReader and then return List;
IList <UserGroupInfo> list = DbSession. Default. From <User> ()
. LeftJoin <Group> (User. _. GroupID = Group. _. GroupID)
. Select (User. _. UserID, User. _. UserName, Group. _. GroupName)
. ToReader () or. ToTable ()
. ToList <UserGroupInfo> ();
If the output columns and attribute values are not available, you can use MySoft. Data. Design. Mapping to mark them:
If the field name is UserID and the attribute name is ID, you can use the following method:
Public class UserGroupInfo: IUserGroupInfo
{
[MySoft. Data. Design. Mapping ("UserID")]
Public int ID {get; private set ;}
Public string UserName {get; private set ;}
Public string GroupName {get; private set ;}
}
// First return ISourceReader and then return List;
IList <UserGroupInfo> list = DbSession. Default. From <User> ()
. LeftJoin <Group> (User. _. GroupID = Group. _. GroupID)
. Select (User. _. UserID, User. _. UserName, Group. _. GroupName)
. ToReader () or. ToTable ()
. ToList <UserGroupInfo> ();
If you use
Public interface IUserGroupInfo
{
Int ID {get; private set ;}
String UserName {get ;}
String GroupName {get ;}
}
You can use the following method for conversion:
IList <IUserGroupInfo> ilist = list. convertize <IUserGroupInfo> ();
3. Added classes for sorting multiple attributes of objects.
SortComparer <Entity> c = new SortComparer <Entity> (
New SortProperty ("PropertyName1"). Asc,
New SortProperty ("PropertyName2"). Desc,
New SortProperty ("PropertyName31"). Asc );
New List (). Sort (c );
Version: 2.7.2
1. Fixed the bug where the Field. IsNull () condition returns an error;
2. Fixed the bug of changing all parameterized values to uppercase when SQL is used for queries or operations.
It was previously modified to meet the requirement that Oracle must be capitalized.
Perform some special processing on Oracle
3. Fixed the bug that cache cannot be performed after where condition parameterization.
Previously, SQL was used for caching, but the parameter names generated each time after parameterization were different, resulting in invalid cache.
Solution: Replace the parameter values with the SQL parameters to achieve SQL consistency.
4. Fixed the bug where the returned results are incorrect when the condition is enumeration.
5. Fixed the bug in calling CacheOff () and CacheOn () methods.
Next Development Plan (MySoft. Data v3.0 ):
1. Added EntityValidator for entity verification. <T>
2. added the MySoft. Data. Linq driver.