When learning XPO, you need to connect to the database and obtain the database server time to connect ORACLESession. DefaultSession. ConnectionnewOracleConnection (DataSourcedbserver; UserIDsystem; Passwordoracle); Session. defacedsession. AutoCreateOptionAutoCreateOpti
When learning XPO, you need to connect to the database and obtain the database server time to connect to the ORACLE Session. defaultSession. connection = new OracleConnection (Data Source = dbserver; User ID = system; Password = oracle); Session. defaultSession. autoCreateOption = AutoCreateOpti
When you start to learn XPO, you need to connect to the database and obtain the database server time to connect to ORACLE
Session. DefaultSession. Connection = new OracleConnection ("Data Source = dbserver; User ID = system; Password = oracle ");
Session. DefaultSession. AutoCreateOption = AutoCreateOption. SchemaOnly;
Session. DefaultSession. Connect ();
Read server time:
Public static class oracleGetsysDate {
Public static DateTime sysDate ()
{
System. Data. IDbCommand command;
// System. Data. IDataReader reader;
Command = DevExpress. Xpo. Session. DefaultSession. Connection. CreateCommand ();
Command. CommandText = "Select sysdate from dual ";
// Reader = command. ExecuteReader ();
String dtm = command. ExecuteScalar (). ToString ();
DateTime jtdtm = DateTime. Parse (dtm );
Return jtdtm;
}
Call:
DateTime dt = oracleGetsysDate. sysDate (). Date;
XPO business class:
Public class TEST: XPLiteObject
{
String fDEPT_CODE;
[Key]
[Size (10)]
[DbType ("varchar2 (30)")] [Persistent ("Dept_code")] [DisplayName ("Department Code")]
Public string DEPT_CODE
{
Get {return fDEPT_CODE ;}
Set {SetPropertyValue ("DEPT_CODE", ref fDEPT_CODE, value );}
}
String fDEPT_NAME;
[Size (30)]
Public string DEPT_NAME
{
Get {return fDEPT_NAME ;}
Set {SetPropertyValue ("DEPT_NAME", ref fDEPT_NAME, value );}
}
DateTime fCREATEDATE;
Public DateTime CREATEDATE
{
Get {return fCREATEDATE ;}
Set {
SetPropertyValue ("CREATEDATE", ref fCREATEDATE, value );}
}
Public TEST (Session session): base (session ){}
Public TEST (): base (Session. DefaultSession ){}
Public override void AfterConstruction () {base. AfterConstruction ();}
Protected override void OnSaving ()
{
Base. OnSaving ();
If (! IsDeleted)
{
UnitOfWork uw = new UnitOfWork ();
If (fDEPT_CODE = null | fDEPT_CODE = "")
Throw new Exception ("the Department Code cannot be null. Saving failed! ");
}
}
Protected override void Spoil (bool disposing)
{
Base. Spoil (disposing );
}
}
Call XPO:
Try
{
DateTime dt = oracleGetsysDate. sysDate (). Date;
Dbserver. TEST test = new TEST ();
Test. DEPT_CODE = "123 ";
Test. DEPT_NAME = "Test2 ";
Test. CREATEDATE = dt;
Test. Save ();
// DateTime dt = oracleGetsysDate. sysDate ();
// This. textBox1.Text = dt. ToString (); // obtain the first column of the first row of the query table.
}
Catch (Exception ex)
{
MessageBox. Show (ex. Message, "prompt ");
}
The Preliminary Study of XPO is relatively simple.