public HowTo_UseTransactions_betweenDOs_operations() {
			string _testid = DateTime.Now.Ticks.ToString();
			bool _constraint;
			long _iduser;
			long _idgroup;

			// we need a shared connection between Data Objects
			DBConnection _con = DO__utils.DBConnection_createInstance(
				DO__utils.DBServerType, 
				DO__utils.DBConnectionstring, 
				string.Empty
			);

			// before beginning a transaction we need to open the connection
			_con.Open();

			// beginning transaction
			_con.Transaction.Begin();

			// sharing connection with User Data Object
			DO_User _user = new DO_User(_con);
			// performing some operations on User Data Object
			_user.Fields.Login = _testid;
			_user.Fields.Password = _testid;
			_iduser = _user.insObject(true, out _constraint);
			// handling constraint code should be added here
			_user.Dispose(); _user = null;

			// sharing connection with Group Data Object
			DO_Group _group = new DO_Group(_con);
			// performing some operations on User Data Object
			_group.Fields.Name = _testid;
			_idgroup = _group.insObject(true);
			_group.Dispose(); _group = null;

			// sharing connection with Group Data Object
			DO_UserGroup _usergroup = new DO_UserGroup(_con);
			// performing some operations on User Data Object
			_usergroup.Fields.IDGroup = _idgroup;
			_usergroup.Fields.IDUser = _iduser;
			_usergroup.Fields.Relationdate = DateTime.Now;
			_usergroup.Fields.Defaultrelation = false;
			_usergroup.setObject(false);
			_usergroup.Dispose(); _usergroup = null;

			// rollback transaction, we don't need such data in db, this is just an how to sample
			_con.Transaction.Rollback();

			// terminate transaction
			_con.Transaction.Terminate();

			// closing connection
			_con.Close();

			_con.Dispose(); _con = null;
		}
예제 #2
0
		internal RO0_Group(
#if !NET_1_1
			DO_Group 
#else
			DO0_Group 
#endif
			parent_ref_in
		) : base(
			parent_ref_in
		) {
			parent_ref_ = parent_ref_in;
		}
예제 #3
0
파일: RO0_Group.cs 프로젝트: katshann/ogen
		internal RO0_Group(
#if USE_PARTIAL_CLASSES && !NET_1_1
			DO_Group 
#else
			DO0_Group 
#endif
			parent_ref_in
		) : base(
			parent_ref_in
		) {
			parent_ref_ = parent_ref_in;
		}
예제 #4
0
        internal RO0_Group(
#if USE_PARTIAL_CLASSES && !NET_1_1
            DO_Group
#else
            DO0_Group
#endif
            parent_ref_in
            ) : base(
                parent_ref_in
                )
        {
            parent_ref_ = parent_ref_in;
        }
예제 #5
0
        internal RO0_Group(
#if !NET_1_1
            DO_Group
#else
            DO0_Group
#endif
            parent_ref_in
            ) : base(
                parent_ref_in
                )
        {
            parent_ref_ = parent_ref_in;
        }
예제 #6
0
파일: UT0_Group.cs 프로젝트: katshann/ogen
		public void UT_InsGetDelSequence() {
			DO_Group _group;
			try {
				_group = new DO_Group();
			} catch (Exception e) {
				Assert.IsTrue(false, "some error trying to instantiate DO_Group\n---\n{0}\n---", e.Message);
				return; // no need...
			}
			_group.Connection.Open();
			_group.Connection.Transaction.Begin();



			_group.Fields.Name = "123";
			long _idgroup;
			try {
				_idgroup = _group.insObject(true);
			} catch (Exception e) {
				Assert.IsTrue(false, "some error running insObject\n---\n{0}\n---", e.Message);
				return; // no need...
			}
			Assert.IsTrue(_idgroup > 0L, "failed to retrieve identity seed (insObject)");
			_group.clrObject();
			bool _exists;
			try {
				_exists = _group.getObject(_idgroup);
			} catch (Exception e) {
				Assert.IsTrue(false, "some error running getObject\n---\n{0}\n---", e.Message);
				return; // no need...
			}
			Assert.IsTrue(_exists, "can't read inserted item (getObject)");
			Assert.AreEqual("123", _group.Fields.Name, "inserted values difer those just read (insObject/getObject)");
			try {
				_group.delObject(_idgroup);
			} catch (Exception e) {
				Assert.IsTrue(false, "some error trying to delete (delObject)\n---\n{0}\n---", e.Message);
				return; // no need...
			}



			_group.Connection.Transaction.Rollback();
			_group.Connection.Transaction.Terminate();
			_group.Connection.Close();
			_group.Dispose(); _group = null;
		}
예제 #7
0
		public void UT_NullableFields() {
			bool _contraint;
			long _iduser;
			long _idgroup;

			for (int c = 0; c < UT0__utils.DBConnections.Length; c++) {
//Console.WriteLine("UT_NullableFields: {0}", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]).ToString());

				UT0__utils.DBConnections[c].Open();
				UT0__utils.DBConnections[c].Transaction.Begin();

				#region _iduser = new DO_User(UT0__utils.DBConnections[c]).insObject(true);
				DO_User _user = new DO_User(UT0__utils.DBConnections[c]);
				_user.Fields.Login = testid_;
				_user.Fields.Password = testid_;
				_iduser = _user.insObject(true, out _contraint);
				_user.Dispose(); _user = null;
				#endregion
				#region _idgroup = new DO_Group(UT0__utils.DBConnections[c]).insObject(true);
				DO_Group _group = new DO_Group(UT0__utils.DBConnections[c]);
				_group.Fields.Name = testid_;
				_idgroup = _group.insObject(true);
				_group.Dispose(); _group = null;
				#endregion

				DO_UserGroup _usergroup = new DO_UserGroup(UT0__utils.DBConnections[c]);
				_usergroup.Fields.IDUser = _iduser;
				_usergroup.Fields.IDGroup = _idgroup;
				_usergroup.Fields.Relationdate_isNull = true;
				_usergroup.Fields.Defaultrelation_isNull = true;
				_usergroup.setObject(true);

				#region test1...
				_usergroup.clrObject();
				_usergroup.getObject(_iduser, _idgroup);
				Assert.IsTrue(_usergroup.Fields.Relationdate_isNull, "DO_UserGroup.Relationdate expected to be nullable ({0})", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]));
				Assert.IsTrue(_usergroup.Fields.Defaultrelation_isNull, "DO_UserGroup.Defaultrelation expected to be nullable ({0})", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]));
				#endregion
				#region test2...
				_usergroup.Record.Open_byUser_Defaultrelation(
					_iduser,
					null
				);
				while (_usergroup.Record.Read()) {
					Assert.IsTrue(_usergroup.Fields.Relationdate_isNull, "DO_UserGroup.Relationdate expected to be nullable ({0})", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]));
					Assert.IsTrue(_usergroup.Fields.Defaultrelation_isNull, "DO_UserGroup.Defaultrelation expected to be nullable ({0})", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]));
				}
				_usergroup.Record.Close();
				#endregion
				#region test3...
				Assert.IsTrue(
					_usergroup.Record.hasObject_byUser_Defaultrelation(
						_iduser,
						_idgroup,
						_iduser,
						null
					), 
					"test error: 1 ({0})", 
					DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c])
				);
				Assert.AreEqual(
					1L,
					_usergroup.Record.Count_byUser_Defaultrelation(
						_iduser,
						null
					), 
					"test error: 2 ({0})", 
					DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c])
				);
				#endregion
				#region test4...
				DateTime _now = DateTime.Now;
				_usergroup.Record.Update_SomeUpdateTest_byUser_Defaultrelation(
					_iduser,
					null,
					_now
				);

				Assert.IsTrue(
					_usergroup.Record.hasObject_byUser_Defaultrelation(
						_iduser,
						_idgroup,
						_iduser,
						_now
					), 
					"test error: 3 ({0})", 
					DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c])
				);
				Assert.AreEqual(
					1L,
					_usergroup.Record.Count_byUser_Defaultrelation(
						_iduser,
						_now
					), 
					"test error: 4 ({0})", 
					DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c])
				);
				#endregion

				_usergroup.Dispose(); _usergroup = null;

				UT0__utils.DBConnections[c].Transaction.Rollback();
				UT0__utils.DBConnections[c].Transaction.Terminate();
				UT0__utils.DBConnections[c].Close();
			}
		}
예제 #8
0
		public void UT_bugPostgreSQL_noFunctionMatchesTheGivenNameAndArgumentTypes() {
			bool _contraint;
			long _iduser;
			long _idgroup;

			for (int c = 0; c < UT0__utils.DBConnections.Length; c++) {
//Console.WriteLine("UT_NullableFields: {0}", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]).ToString());

				UT0__utils.DBConnections[c].Open();
				UT0__utils.DBConnections[c].Transaction.Begin();

				#region _iduser = new DO_User(UT0__utils.DBConnections[c]).insObject(true);
				DO_User _user = new DO_User(UT0__utils.DBConnections[c]);
				_user.Fields.Login = testid_;
				_user.Fields.Password = testid_;
				_iduser = _user.insObject(true, out _contraint);
				_user.Dispose(); _user = null;
				#endregion
				#region _idgroup = new DO_Group(UT0__utils.DBConnections[c]).insObject(true);
				DO_Group _group = new DO_Group(UT0__utils.DBConnections[c]);
				_group.Fields.Name = testid_;
				_idgroup = _group.insObject(true);
				_group.Dispose(); _group = null;
				#endregion

				DO_UserGroup _usergroup = new DO_UserGroup(UT0__utils.DBConnections[c]);
				_usergroup.Fields.IDUser = _iduser;
				_usergroup.Fields.IDGroup = _idgroup;
				_usergroup.Fields.Relationdate_isNull = true;
				_usergroup.Fields.Defaultrelation_isNull = true;
				try {
					_usergroup.setObject(true);
				} catch {
					Assert.Fail(
						"test error: 1 ({0})",
						DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c])
					);
				}
				_usergroup.Dispose(); _usergroup = null;

				UT0__utils.DBConnections[c].Transaction.Rollback();
				UT0__utils.DBConnections[c].Transaction.Terminate();
				UT0__utils.DBConnections[c].Close();
			}
		}