public void CastToByte() { Employee emp = new Employee(); emp.es.Connection.Name = "ForeignKeyTest"; emp.Query.Select((esByte)emp.Query.Age.As("CastColumn")); emp.Query.Where(emp.Query.EmployeeID == 1); switch (emp.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.MSAccessProvider": case "EntitySpaces.MySqlClientProvider": case "EntitySpaces.OracleClientProvider": case "EntitySpaces.NpgsqlProvider": case "EntitySpaces.Npgsql2Provider": case "EntitySpaces.SQLiteProvider": //case "EntitySpaces.SqlServerCeProvider": Assert.Ignore("Not supported."); break; default: Assert.IsTrue(emp.Query.Load()); byte value = 30; object obj = emp.GetColumn("CastColumn"); Assert.AreEqual("System.Byte", obj.GetType().ToString()); Assert.AreEqual(value, obj); break; } }
public void CastToChar() { Employee emp = new Employee(); emp.es.Connection.Name = "ForeignKeyTest"; emp.Query.Where(emp.Query.EmployeeID == 1); switch (emp.es.Connection.ProviderSignature.DataProviderName) { //case "EntitySpaces.MySqlClientProvider": //case "EntitySpaces.NpgsqlProvider": //case "EntitySpaces.Npgsql2Provider": //case "EntitySpaces.VistaDBProvider": //case "EntitySpaces.SQLiteProvider": case "EntitySpaces.MSAccessProvider": case "EntitySpaces.SqlServerCeProvider": case "EntitySpaces.SqlServerCe4Provider": Assert.Ignore("Not supported."); break; case "EntitySpaces.OracleClientProvider": emp.Query.Select(emp.Query.FirstName.Cast(esCastType.Char, 25).As("CastColumn")); Assert.IsTrue(emp.Query.Load()); //string value = "John"; object obj = emp.GetColumn("CastColumn"); Assert.AreEqual("System.String", obj.GetType().ToString()); //Assert.AreEqual(value, obj); break; default: emp.Query.Select((esChar)emp.Query.FirstName.As("CastColumn")); Assert.IsTrue(emp.Query.Load()); //string value = "John"; obj = emp.GetColumn("CastColumn"); Assert.AreEqual("System.String", obj.GetType().ToString()); //Assert.AreEqual(value, obj); break; } }
public void CastToDateTime() { int empId = 0; try { using (esTransactionScope scope = new esTransactionScope()) { // Create an employee with a date in the LastName column Employee emp = new Employee(); emp.es.Connection.Name = "ForeignKeyTest"; switch (emp.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.OracleClientProvider": emp.LastName = "31-DEC-2008 01:01:01"; break; default: emp.LastName = "2008-12-31"; break; } emp.FirstName = "required"; emp.Save(); empId = emp.EmployeeID.Value; emp = new Employee(); emp.es.Connection.Name = "ForeignKeyTest"; emp.Query.Select((esDateTime)emp.Query.LastName.As("CastColumn")); emp.Query.Where(emp.Query.EmployeeID == empId); switch (emp.es.Connection.ProviderSignature.DataProviderName) { //case "EntitySpaces.MySqlClientProvider": //case "EntitySpaces.NpgsqlProvider": //case "EntitySpaces.Npgsql2Provider": //case "EntitySpaces.VistaDBProvider": case "EntitySpaces.MSAccessProvider": case "EntitySpaces.SQLiteProvider": //case "EntitySpaces.SqlServerCeProvider": Assert.Ignore("Not supported."); break; case "EntitySpaces.OracleClientProvider": string lq = emp.Query.Parse(); Assert.IsTrue(emp.Query.Load()); DateTime value = DateTime.Parse("2008-12-31 01:01:01"); object obj = emp.GetColumn("CastColumn"); Assert.AreEqual("System.DateTime", obj.GetType().ToString()); Assert.AreEqual(value, obj); break; default: lq = emp.Query.Parse(); Assert.IsTrue(emp.Query.Load()); value = DateTime.Parse("2008-12-31"); obj = emp.GetColumn("CastColumn"); Assert.AreEqual("System.DateTime", obj.GetType().ToString()); Assert.AreEqual(value, obj); break; } } } finally { Employee emp = new Employee(); emp.es.Connection.Name = "ForeignKeyTest"; emp.Query.Where(emp.Query.EmployeeID == empId); if (emp.Query.Load()) { emp.MarkAsDeleted(); emp.Save(); } } }