public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // you now have a DataTable populated // with results from your sql query System.Data.DataTable _datatable = _con.Execute_SQLQuery_returnDataTable( "select * from \"CRD_User\"" ); _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // you now have a string array populated with all // databases (except system ones) at you db server string[] _dbs = _con.SchemaDatabases(); _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // executing your sql query _con.Execute_SQLQuery( "delete from \"CRD_User\" where \"IDUser\" = -1" // it does nothing, this is just an example ); _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // you now have a cDBTableField array populated with all // field names and other properties for specified table OGen.Libraries.DataLayer.DBTableField[] _fields = _con.SchemaDatabaseTableFields("CRD_User"); for (int f = 0; f < _fields.Length; f++) { Console.WriteLine( "field name: {0}\nis PK: {1}\nis Identity: {2}\nis nullable: {3}", _fields[f].Name, _fields[f].IsPK, _fields[f].IsIdentity, _fields[f].IsNullable, // many other properties available, like: _fields[f].DBCollationName, _fields[f].DBDefaultValue, _fields[f].DBDescription, _fields[f].ForeignKey_TableName, _fields[f].ForeignKey_TableFieldName, _fields[f].Numeric_Precision, _fields[f].Numeric_Scale, _fields[f].Size ); } _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> long _iduser = 1L; OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // set your function parameters System.Data.IDbDataParameter[] _dataparameters = new System.Data.IDbDataParameter[] { _con.newDBDataParameter( "IDUser_", System.Data.DbType.Int64, System.Data.ParameterDirection.Input, _iduser, 0 ) }; // call you function and get returning value bool _result = (bool)_con.Execute_SQLFunction( "fnc0_CRD_User_isObject", _dataparameters, System.Data.DbType.Boolean, // returning value db type 0 // returning value size, if applicable ); _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> long _iduser_search = 1L; OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // set your function parameters System.Data.IDbDataParameter[] _dataparameters = new System.Data.IDbDataParameter[] { _con.newDBDataParameter( "IDUser_search_", System.Data.DbType.Int64, System.Data.ParameterDirection.Input, _iduser_search, 0 ) }; // you now have a DataTable populated // with results from your sql function System.Data.DataTable _datatable = _con.Execute_SQLFunction_returnDataTable( "sp0_CRD_UserProfile_Record_open_byUser", _dataparameters ); _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); // you now have a cDBTable array populated with all // table names and other properties for your database OGen.Libraries.DataLayer.DBTable[] _tables = _con.SchemaDatabaseTables(); for (int t = 0; t < _tables.Length; t++) { Console.WriteLine( "table name: {0}\nis this a view and not a table: {1}", _tables[t].Name, _tables[t].IsVirtualTable ); } _con.Dispose(); _con = null; //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> string _testid = DateTime.Now.Ticks.ToString(); bool _constraint; long _iduser; long _ifprofile; // we need a shared connection between Data Objects OGen.Libraries.DataLayer.DBConnection _con = OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBConnection_createInstance( OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBServerType, OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBConnectionstring, string.Empty ); Exception _exception = null; try { // before beginning a transaction we need to open the connection _con.Open(); // beginning transaction _con.Transaction.Begin(); OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User(); // performing some operations on User Data Object _user.Login = _testid; _user.Password = _testid; _user.IFApplication_isNull = true; // sharing connection with User Data Object _iduser = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_User.insObject( _user, true, out _constraint, _con ); // handling constraint code should be added here OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_Profile _profile = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_Profile(); // performing some operations on User Data Object _profile.Name = _testid; _profile.IFApplication_isNull = true; // sharing connection with Group Data Object _ifprofile = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_Profile.insObject( _profile, true, _con ); OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_UserProfile _userprofile = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_UserProfile(); // performing some operations on User Data Object _userprofile.IFProfile = _ifprofile; _userprofile.IFUser = _iduser; // sharing connection with Group Data Object OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_UserProfile.setObject( _userprofile, false, _con ); // commit transaction _con.Transaction.Commit(); } catch (Exception _ex) { // rollback transaction _con.Transaction.Rollback(); _exception = _ex; } finally { //// terminate transaction //if (_con.Transaction.InTransaction) { // _con.Transaction.Terminate(); //} //// closing connection //if (_con.IsOpen) { // _con.Close(); //} // no need to (conditionally) terminate transaction and close connection, // simply disposing connection will do all that _con.Dispose(); _con = null; } if (_exception != null) { throw _exception; } //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }
public void HowTo() { //<document> OGen.Libraries.DataLayer.DBConnection _con = OGen.Libraries.DataLayer.DBConnectionsupport.CreateInstance( // set your db server type here OGen.Libraries.DataLayer.DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=KickUnitTests;" ); Exception _exception = null; try { // before beginning a transaction we need to open the connection _con.Open(); // beginning transaction _con.Transaction.Begin(); // performing some operations on database _con.Execute_SQLQuery( "delete from \"CRD_User\" where \"IDUser\" = -1" // it does nothing, this is just an example ); // commit transaction _con.Transaction.Commit(); } catch (Exception _ex) { // rollback transaction _con.Transaction.Rollback(); _exception = _ex; } finally { //// terminate transaction //if (_con.Transaction.InTransaction) { // _con.Transaction.Terminate(); //} //// closing connection //if (_con.IsOpen) { // _con.Close(); //} // no need to (conditionally) terminate transaction and close connection, // simply disposing connection will do all that _con.Dispose(); _con = null; } if (_exception != null) { throw _exception; } //</document> // the only porpuses is to keep documentation code samples updated by: // 1) ensure documentation code samples are compiling // 2) no exceptions are beeing thrown by documentation code samples Assert.IsTrue( true, "documentation code sample is failing" ); }