MySQL database is supported, and SPL is upgraded to 3.2

Source: Internet
Author: User
Tags spl
This article mainly describes how to upgrade SPL to 3.2 to fully support the practical application and specific operations of MySQL databases. If you are a beginner in MySQL databases, if you are not familiar with the actual application of the MySQL database, the following articles will provide you with more comprehensive knowledge. After a period of time, the SPL has made some modifications and made progress.

This article mainly describes how to upgrade SPL to 3.2 to fully support the practical application and specific operations of MySQL databases. If you are a beginner in MySQL databases, if you are not familiar with the actual application of the MySQL database, the following articles will provide you with more comprehensive knowledge. After a period of time, the SPL has made some modifications and made progress.

This article mainly describes how to upgrade SPL to 3.2 to fully support the practical application and specific operations of MySQL databases. If you are a beginner in MySQL databases, if you are not familiar with the actual application of the MySQL database, the following articles will provide you with more comprehensive knowledge.

After a period of time, SPL has made some modifications and supported the MySQL database since its last version 3.1.0.5. Now SPL version 3.2.0.4 is released. Dll: Here. You only need to overwrite the original Dll in the project. If you have not downloaded any earlier versions of SPL, the SPL has been updated since 3.1.0.5 last released:

1. Support for Bit data types in MS SQL SERVER

The Type mapped to ClassMap is boolean, for example:

 
 

The corresponding object class type is bool, for example:

 
 
  1. private bool m_IsOver;
  2. public bool IsOver
  3. {
  4. get
  5. {
  6. return this.m_IsOver;
  7. }
  8. set
  9. {
  10. this.m_IsOver = value;
  11. }
  12. }

You can use Condition to compare and judge the query results:

 
 
  1. Codition c=....
  2. c.AddEqualTo("IsOver",false);

This will generate the query condition of IsOver = '0 '.

2. The provider type of the data source can be determined, which facilitates the manual assembly of different SQL statements by different MySQL database providers.

Use Setting. Instance (). GetDatabaseVendor (dbName) to obtain the data source provider based on the dbName data source, and then compare it with the DatabaseVendor Enumeration type.

For example, the Access date is different from that of SQL Server: one uses the # sign and the other uses the 'sign

 
 
  1. if(Setting.Instance().GetDatabaseVendor(dbName)==DatabaseVendor.MsAccess)
  2. {
  3. builder.Append(" and SpecialPriceD2.FromDate<=#"+itemDate.Day.ToString()+"-"+itemDate.Month.ToString()+"-"+itemDate.Year.ToString()+"#");
  4. builder.Append(" and SpecialPriceD2.ToDate>=#"+itemDate.Day.ToString()+"-"+itemDate.Month.ToString()+"-"+itemDate.Year.ToString()+"#");
  5. }
  6. if(Setting.Instance().GetDatabaseVendor(dbName)==DatabaseVendor.MsSqlServer)
  7. {
  8. builder.Append(" and SpecialPriceD2.FromDate<='"+itemDate.Day.ToString()+"-"+itemDate.Month.ToString()+"-"+itemDate.Year.ToString()+"'");
  9. builder.Append(" and SpecialPriceD2.ToDate>='"+itemDate.Day.ToString()+"-"+itemDate.Month.ToString()+"-"+itemDate.Year.ToString()+"'");
  10. }

This function provides the best flexibility for the system to support a variety of MySQL databases. Although the "entity" and "standard" of SPL can distinguish different data source providers, however, where you need to write SQL, you also need to provide different statements for execution based on different data source providers.

3. modified the compatibility of all reserved words

Currently, the delimiters are added to all SPL operations. ORACLE uses the "" number, MS uses the "[]" number, and MySql uses the "'" number, all tests passed

4. added the Null value query function in Condition.

This method is only valid for AddEqualTo () and AddNotEqualTo:

 
 
  1. C. AddEqualTo ("field name", System. DBNull. Value );
  2. C. AddNotEqualTo ("field name", System. DBNull. Value );

5. Added support for the MySql database.

SPL uses the dedicated connection provided by MySql to access MySql. NET connector, the driver should be said to be currently. NET is the best choice for connecting to MySql. When using SPL to access MySql, you only need to install this driver. For download and introduction, see

You only need to set the DatabaseMap type to "MySql" when using it, as shown below:

 
 

After configuration, SPL is exactly the same as others in a specific application. Test conditions:

Entity test ---> pass

RetrieveCriteira, UpdateCriteria, and DeleteCriteria test ---> pass

Transaction test ---> pass

Auto-increment primary key test ---> pass

TOP function test ---> pass

6. The DateTime Null value is processed (supported at the beginning of 3.2.0.1)

To assign a Null value to a field of the DateTime type, you only need to use DateTime. MinValue:

AEntity. CreateDate = DateTime. MinValue;

In the SPL, it will determine if DateTime. minValue is automatically saved to the MySQL database as System. DBNull. value. DBNull. value.

7. Errors Caused by inconsistent attribute names and field names in UpdateCriteria (revision started at 3.2.0.2)

In the past, when UpdateCriteira did not convert the attribute to the field name, the field cannot be found if the attribute name is different from the field name.

(Thank you very much for the suggestions provided by iamsunrise. Please download SPL3.2 again)
(Thanks to the BUG reported by Zi Yang)

8. The MySql type of DataBaseType has been fixed in 3.2.0.4.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.