public void Disjunction() { ICriteriaBuilder cb = EJBContainer.Instance.EntityManager.GetCriteriaBuilder(); ICriteriaQuery cq = cb.CreateQuery(); IRoot r = cq.From("Students"); IPredicate criteria = cb.Disjunction(); IParameterExpression pr = cb.Parameter(System.Data.SqlDbType.Int, "3"); criteria = cb.Or(criteria, cb.Equal(r.Get("SequenceNumber"), pr) ); pr = cb.Parameter(System.Data.SqlDbType.Int, "'Jonas'"); criteria = cb.Or(criteria, cb.Equal(r.Get("FirstName"), pr) ); pr = cb.Parameter(System.Data.SqlDbType.Int, "'Petraitis'"); criteria = cb.Or(criteria, cb.Equal(r.Get("LastName"), pr) ); Assert.AreEqual("Students.SequenceNumber = 3 OR Students.FirstName = 'Jonas' OR Students.LastName = 'Petraitis'", criteria.ExpressionValue); }
public void ParameterExpressoin_IntType() { ICriteriaBuilder cb = EJBContainer.Instance.EntityManager.GetCriteriaBuilder(); ICriteriaQuery cq = cb.CreateQuery(); IRoot r = cq.From("Students"); IParameterExpression pr = cb.Parameter(System.Data.SqlDbType.Int, "3"); IPredicate exp = cb.Equal(r.Get("SequenceNumber"), pr); Assert.AreEqual("Students.SequenceNumber = 3", exp.ExpressionValue); }
public void ParameterExpressoin_StringType() { ICriteriaBuilder cb = EJBContainer.Instance.EntityManager.GetCriteriaBuilder(); ICriteriaQuery cq = cb.CreateQuery(); IRoot r = cq.From("Students"); IParameterExpression pr = cb.Parameter(System.Data.SqlDbType.VarChar, "Jonas"); IPredicate exp = cb.Equal(r.Get("FirstName"), pr); Assert.AreEqual("Students.FirstName = 'Jonas'", exp.ExpressionValue); }