public void EmptyQueryReturnsSelectAll()
		{
			aggTestColl = new FullNameViewCollection();
            if (aggTestColl.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
            {
                Assert.IsTrue(aggTestColl.LoadAll());
                Assert.AreEqual(16, aggTestColl.Count, "LoadAll");
            }

			aggTestColl = new FullNameViewCollection();
			Assert.IsTrue(aggTestColl.Query.Load());
			Assert.AreEqual(16, aggTestColl.Count, "Query.Load");

			aggTestColl = new FullNameViewCollection();
			aggTestColl.Query.LoadDataTable();
			Assert.AreEqual(0, aggTestColl.Count, "Query.LoadDataTable");
		}
 public void CollectionCustomLoadFromViewByDept()
 {
     if (aggTestColl.es.Connection.Name == "SqlCe"
         || aggTestColl.es.Connection.ProviderMetadataKey ==
         "esSqlCe4"
         || aggTestColl.es.Connection.ProviderMetadataKey ==
         "esSqlCe")
     {
         Assert.Ignore("Not tested for SqlCe.");
     }
     else
     {
         viewColl = new FullNameViewCollection();
         viewColl.CustomLoadFromViewByDept(1);
         Assert.AreEqual(2, viewColl.Count);
     }
 }
		public void CollectionCustomLoadFromViewNoParams()
		{
            viewColl = new FullNameViewCollection();

            if (viewColl.es.Connection.Name == "SqlCe"
                || aggTestColl.es.Connection.ProviderMetadataKey ==
                "esSqlCe4"
                || aggTestColl.es.Connection.ProviderMetadataKey ==
                "esSqlCe")
            {
                Assert.Ignore("Not tested for SqlCe.");
            }
            else
            {
                string whereClause = "";

                switch (viewColl.es.Connection.ProviderSignature.DataProviderName)
                {
                    case "EntitySpaces.NpgsqlProvider":
                    case "EntitySpaces.Npgsql2Provider":
                    case "EntitySpaces.OracleClientProvider":
                        whereClause = "WHERE \"DepartmentID\" = 1 ";
                        whereClause += "OR \"DepartmentID\" = 2 ";
                        break;

                    case "EntitySpaces.MySqlClientProvider":
                        whereClause = "WHERE `DepartmentID` = 1 ";
                        whereClause += "OR `DepartmentID` = 2";
                        break;

                    default:
                        whereClause = "WHERE [DepartmentID] = 1 ";
                        whereClause += "OR [DepartmentID] = 2";
                        break;
                }
                viewColl.CustomLoadFromViewNoParams(whereClause);
                Assert.AreEqual(6, viewColl.Count);
            }
		}
		public void Init2()
		{
			aggTestColl = new FullNameViewCollection();
			aggTest = new FullNameView();
			aggTestQuery = new FullNameViewQuery();
		}
        private void buttonQuery_Click(object sender, EventArgs e)
        {
            FullNameViewCollection coll = new FullNameViewCollection();
            coll.es.Connection.Name = "SQLiteAggregateDb";

            try
            {
                //FullNameViewQuery vwQuery = new FullNameViewQuery();
                //vwQuery.Select(vwQuery.FullName, vwQuery.HireDate);
                //coll.Load(vwQuery);

                coll.Query.Select
                (
                    coll.Query.FullName.As(FullNameViewMetadata.PropertyNames.FullName),
                    coll.Query.HireDate.As(FullNameViewMetadata.PropertyNames.HireDate)
                );
                coll.Query.Load();

                //coll.LoadAll();

                int i = 0;
                foreach (FullNameView entity in coll)
                {
                    i++;
                    Debug.WriteLine(i.ToString() + " : " + entity.HireDate + " : " + entity.FullName);
                }

                if (coll != null)
                {
                    textBox1.Text = "Row count: " + coll.Count + "\r\n\r\n";
                }
                else
                {
                    textBox1.Text = "Collection is null.\r\n";
                }

                if (coll.Query.es.LastQuery != null)
                {
                    textBox1.Text += FormatLastQuery(coll.Query.es.LastQuery);
                }
                else
                {
                    textBox1.Text += "LastQuery is null.";
                }

                bindingSource1.DataSource = coll;
                dataGridView1.DataSource = bindingSource1;

                //coll.Filter = coll.AsQueryable().Where(d => 
                //    d.BirthDate >= Convert.ToDateTime("1950-01-01")
                //    && d.BirthDate <= Convert.ToDateTime("1959-12-31"));
            }
            catch (Exception ex)
            {
                textBox1.Text = ex.ToString();

                if (coll.Query.es.LastQuery != null)
                {
                    textBox1.Text += "\r\n\r\n";
                    textBox1.Text += FormatLastQuery(coll.Query.es.LastQuery);
                }
            }
        }