public void ShouldCreateAliasExpression()
        {
            var factory    = new DbExpressionFactory();
            var expression = factory.Alias(factory.Column("SomeColumn"), "sc");

            Assert.IsNotNull(expression.Target);
            Assert.IsNotNull(expression.Alias);
            Assert.IsTrue(expression.ExpressionType == DbExpressionType.Alias);
        }
        public void ShouldReplaceExpressionsOfParticularTypeUsingPredicate()
        {
            var factory       = new DbExpressionFactory();
            var dbSelectQuery = new DbSelectQuery();
            var expression    = dbSelectQuery.Select(f => f.Column("SomeColumn")).From(f => f.Table("SomeTable"));

            expression.Replace <DbTableExpression>(te => true, te => factory.Alias(te, "t0"));
            var result = expression.Find <DbAliasExpression>(ae => true);

            Assert.IsTrue(result.Count() == 1);
        }
 public void ShouldCreateAliasExpression()
 {
     var factory = new DbExpressionFactory();
     var expression = factory.Alias(factory.Column("SomeColumn"), "sc");
     Assert.IsNotNull(expression.Target);
     Assert.IsNotNull(expression.Alias);
     Assert.IsTrue(expression.ExpressionType == DbExpressionType.Alias);
 }
 public void ShouldReplaceExpressionsOfParticularTypeUsingPredicate()
 {
     var factory = new DbExpressionFactory();
     var dbSelectQuery = new DbSelectQuery();
     var expression = dbSelectQuery.Select(f => f.Column("SomeColumn")).From(f => f.Table("SomeTable"));
     expression.Replace<DbTableExpression>(te => true, te => factory.Alias(te, "t0"));
     var result = expression.Find<DbAliasExpression>(ae => true);
     Assert.IsTrue(result.Count() == 1);
 }
예제 #5
0
 /// <summary>
 /// Creates a new <see cref="DbAliasExpression"/> for the target <paramref name="dbExpression"/>.
 /// </summary>
 /// <param name="dbExpression">The <see cref="DbExpression"/> to be aliased.</param>
 /// <param name="alias">The alias.</param>
 /// <returns>A <see cref="DbAliasExpression"/> instance.</returns>
 public static DbAliasExpression As(this DbExpression dbExpression, string alias)
 {
     return(ExpressionFactory.Alias(dbExpression, alias));
 }