This section describes how to apply the previous scenario to improve performance in GIX4 systems, if integrated with existing system environments. Contains roughly the following:
Generation of SQL
Mapping-data-reading scenarios
Factory Method-naming convention for interfaces
Instance Code
SQL generation
GIX4 all domain models and distributed access mechanisms in the system, using CSLA as the underlying framework. And the ORM mechanism, using a very lightweight open source code liteorm implementation. The definition of the model class takes the following format:
As you can see, in the metadata definition of a class, which is now in the form of an attribute, it already contains information about the corresponding datasheet and columns. So for the automation of SQL to provide a certain support.
In fact, because of the low performance requirements of the module, so the SQL used to optimize the query mainly rely on manual handwriting. But because the Liteorm framework has a limited function, the tabular data we query here needs to be read and encapsulated by ourselves. Taking into account: 1. Column names may be duplicated when multiple tables are connected, 2. Do not change handwritten SQL when adding/removing columns. So at least the column names should be generated automatically and not duplicated. We put the API that generates the column name SQL in the base class gentity<t> of all models, as follows:
[Serializable]
public abstract class GEntity<T> : Entity<T>
where T : GEntity<T>
{
#region 直接与数据行进行交互
<summary>
Fetch data directly from the data set.
///
Attention:
The column field convention in the DataSet is: "Table name _ column name", such as "Pbs_name".
Use reflection to create objects and read data by default! With "Liteorm".
///
Significance:
Because the column names of each class are no longer the same, the meaning of this method is that you can load an aggregate object with a complex combination of SQL!
</summary>
<param name= "RowData" >
The column field convention in this dataset is: "Table name _ column name", such as "Pbs_name".
</param>
<returns>
If the ID value is NULL, NULL is returned.
</returns>
public static T readdatadirectly (DataRow rowdata)
<summary>
Gets the column name notation that can be read by the readdirectly method. Such as:
Pbs. Id as pbs_id, PBS. Name as Pbs_name, ...
</summary>
<returns></returns>
public static string Getreadablecolumnssql ()
<summary>
Gets the column name notation that can be read by the readdirectly method. Such as:
P.id as pbs_id, p.name as Pbs_name, ...
</summary>
<param name= "Tablealias" > table í? e name?</param>
<returns></returns>
public static string Getreadablecolumnssql (String tablealias)
<summary>
Gets the name of the column that is columnname when used in DataRow.
</summary>
<param name= "ColumnName" ></param>
<returns></returns>
public static string Getreadablecolumnsql (String columnName)
public static itable GetTableInfo ()
{
When you load table information here, you may need to interact with the server.
if (Helper.isonserver ())
{
return Gettableinfo_onserver ();
}
Else
{
return Gettableinfo_onclient ();
}
}
#endregion