public void EntityLoadByPrimaryKeyChar()
        {
            CustomerGroup cg = new CustomerGroup();
            cg.es.Connection.Name = "ForeignKeyTest";

            Assert.IsTrue(cg.LoadByPrimaryKey("05001"));
        }
		public void TestNullReferences()
		{
			CustomerGroup cg = new CustomerGroup();
            cg.es.Connection.Name = "ForeignKeyTest";

            cg.LoadByPrimaryKey("99999");
			Assert.IsFalse(cg.Group.es.HasData);
		}
		public void TestReferences()
		{
			CustomerGroup cg = new CustomerGroup();
            cg.es.Connection.Name = "ForeignKeyTest";

            Assert.IsTrue(cg.LoadByPrimaryKey("05001"));
			Assert.IsTrue(cg.Group.es.HasData);
		}
        static public void Delete(System.String groupID, esSqlAccessType sqlAccessType)
        {
            var obj = new CustomerGroup();

            obj.GroupID = groupID;
            obj.AcceptChanges();
            obj.MarkAsDeleted();
            obj.Save(sqlAccessType);
        }
		public void TestSaveWithoutAutoKey()
		{
            CustomerGroup cg = new CustomerGroup();
            cg.es.Connection.Name = "ForeignKeyTest";
            Group g = new Group();
            g.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    cg.GroupID = "XXXXy";
                    cg.GroupName = "Test Group";

                    g = cg.Group;
                    g.Id = cg.GroupID;
                    g.Notes = "Some Text";

                    cg.Save();

                    Assert.IsTrue(cg.Group.es.HasData);
                    Assert.AreEqual(cg.GroupID, cg.Group.Id);
                }
            }
            finally
            {
                // Clean up
                cg = new CustomerGroup();
                cg.es.Connection.Name = "ForeignKeyTest";

                if (cg.LoadByPrimaryKey("XXXXy"))
                {
                    g = cg.Group;
                    g.MarkAsDeleted();
                    cg.MarkAsDeleted();
                    cg.Save();
                }
            }
		}
 public CustomerGroupProxyStub(CustomerGroup obj, bool dirtyColumnsOnly)
 {
     theEntity             = this.entity = obj;
     this.dirtyColumnsOnly = dirtyColumnsOnly;
 }
 public CustomerGroupProxyStub(CustomerGroup obj)
 {
     theEntity = this.entity = obj;
 }
		public void TestSave()
		{
            int empKey = -1;
            CustomerGroup custGroup = new CustomerGroup();
            custGroup.es.Connection.Name = "ForeignKeyTest";
            Employee emp = new Employee();
            emp.es.Connection.Name = "ForeignKeyTest";
            Customer cust = new Customer();
            cust.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    custGroup.GroupID = "XXXXX";
                    custGroup.GroupName = "Test";
                    custGroup.Save();

                    emp.LastName = "LastName";
                    emp.FirstName = "FirstName";

                    cust = emp.CustomerCollectionByStaffAssigned.AddNew();
                    cust.CustomerID = "XXXXX";
                    cust.CustomerSub = "XXX";
                    cust.CustomerName = "Test";
                    cust.str().DateAdded = "2007-01-01 00:00:00";
                    cust.Active = true;
                    cust.Manager = 1;

                    emp.Save();
                    empKey = emp.EmployeeID.Value;

                    Assert.AreEqual(1, emp.CustomerCollectionByStaffAssigned.Count);
                    Assert.AreEqual(emp.EmployeeID.Value, cust.StaffAssigned.Value);
                }
            }
            finally
            {
                // Clean up
                emp = new Employee();
                emp.es.Connection.Name = "ForeignKeyTest";

                if (emp.LoadByPrimaryKey(empKey))
                {
                    CustomerCollection custColl = emp.CustomerCollectionByStaffAssigned;
                    custColl.MarkAllAsDeleted();
                    emp.MarkAsDeleted();
                    emp.Save();

                }

                custGroup = new CustomerGroup();
                custGroup.es.Connection.Name = "ForeignKeyTest";

                if (custGroup.LoadByPrimaryKey("XXXXX"))
                {
                    custGroup.MarkAsDeleted();
                    custGroup.Save();
                }
            }
		}
        public void TestMultiDeleteEntity()
        {
            int empKey = -1;
            int ordKey = -1;
            CustomerGroup custGroup = new CustomerGroup();
            custGroup.es.Connection.Name = "ForeignKeyTest";
            EmployeeCollection empColl = new EmployeeCollection();
            empColl.es.Connection.Name = "ForeignKeyTest";
            Employee emp = new Employee();
            emp.es.Connection.Name = "ForeignKeyTest";
            Employee testEmp = new Employee();
            testEmp.es.Connection.Name = "ForeignKeyTest";
            Customer cust = new Customer();
            cust.es.Connection.Name = "ForeignKeyTest";
            Order ord = new Order();
            ord.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    // Setup
                    custGroup.GroupID = "YYYYY";
                    custGroup.GroupName = "Test";
                    custGroup.Save();

                    emp = empColl.AddNew();
                    emp.LastName = "LastName";
                    emp.FirstName = "FirstName";

                    cust = emp.CustomerCollectionByStaffAssigned.AddNew();
                    cust.CustomerID = "YYYYY";
                    cust.CustomerSub = "YYY";
                    cust.CustomerName = "Test";
                    cust.str().DateAdded = "2007-01-01 00:00:00";
                    cust.Active = true;
                    cust.Manager = 1;

                    ord = emp.OrderCollectionByEmployeeID.AddNew();
                    ord.CustID = "YYYYY";
                    ord.CustSub = "YYY";
                    ord.str().OrderDate = "2007-01-01";

                    empColl.Save();
                    empKey = emp.EmployeeID.Value;
                    ordKey = ord.OrderID.Value;

                    Assert.AreEqual(1, emp.CustomerCollectionByStaffAssigned.Count);
                    Assert.AreEqual(1, emp.OrderCollectionByEmployeeID.Count);
                    Assert.AreEqual(emp.EmployeeID.Value, cust.StaffAssigned.Value);
                    Assert.AreEqual(emp.EmployeeID.Value, ord.EmployeeID.Value);

                    // Test
                    testEmp.LoadByPrimaryKey(empKey);
                    testEmp.OrderCollectionByEmployeeID.MarkAllAsDeleted();
                    testEmp.CustomerCollectionByStaffAssigned.MarkAllAsDeleted();
                    testEmp.MarkAsDeleted();
                    testEmp.Save();

                    emp = new Employee();
                    emp.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(emp.LoadByPrimaryKey(empKey));

                    ord = new Order();
                    ord.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(ord.LoadByPrimaryKey(ordKey));

                    cust = new Customer();
                    cust.es.Connection.Name = "ForeignKeyTest";
                    Assert.IsFalse(cust.LoadByPrimaryKey("YYYYY", "YYY"));
                }
            }
            finally
            {
                // Clean up
                ord = new Order();
                ord.es.Connection.Name = "ForeignKeyTest";
                if (ord.LoadByPrimaryKey(ordKey))
                {
                    ord.MarkAsDeleted();
                    ord.Save();
                }

                cust = new Customer();
                cust.es.Connection.Name = "ForeignKeyTest";
                if (cust.LoadByPrimaryKey("YYYYY", "YYY"))
                {
                    cust.MarkAsDeleted();
                    cust.Save();
                }

                emp = new Employee();
                emp.es.Connection.Name = "ForeignKeyTest";
                if (emp.LoadByPrimaryKey(empKey))
                {
                    emp.MarkAsDeleted();
                    emp.Save();
                }

                custGroup = new CustomerGroup();
                custGroup.es.Connection.Name = "ForeignKeyTest";

                if (custGroup.LoadByPrimaryKey("YYYYY"))
                {
                    custGroup.MarkAsDeleted();
                    custGroup.Save();
                }
            }
        }
		public void TestSaveComposite()
		{
            int ordKey = -1;
            CustomerGroup custGroup = new CustomerGroup();
            custGroup.es.Connection.Name = "ForeignKeyTest";
            Customer cust = new Customer();
            cust.es.Connection.Name = "ForeignKeyTest";
            Order ord = new Order();
            ord.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    custGroup.GroupID = "XXXXX";
                    custGroup.GroupName = "Test";
                    custGroup.Save();

                    cust.CustomerID = "XXXXX";
                    cust.CustomerSub = "XXX";
                    cust.CustomerName = "Test";
                    cust.str().DateAdded = "2007-01-01 00:00:00";
                    cust.Active = true;
                    cust.Manager = 1;

                    ord = cust.OrderCollectionByCustID.AddNew();
                    ord.str().OrderDate = "2007-12-31 00:00:00";

                    cust.Save();
                    ordKey = ord.OrderID.Value;

                    Assert.AreEqual(1, cust.OrderCollectionByCustID.Count);
                }
            }
            finally
            {
                // Clean up
                cust = new Customer();
                cust.es.Connection.Name = "ForeignKeyTest";

                if (cust.LoadByPrimaryKey("XXXXX", "XXX"))
                {
                    OrderCollection ordColl = cust.OrderCollectionByCustID;
                    ordColl.MarkAllAsDeleted();
                    cust.MarkAsDeleted();
                    cust.Save();
                }

                custGroup = new CustomerGroup();
                custGroup.es.Connection.Name = "ForeignKeyTest";

                if (custGroup.LoadByPrimaryKey("XXXXX"))
                {
                    custGroup.MarkAsDeleted();
                    custGroup.Save();
                }
            }
		}